global: snapshot

This commit is contained in:
nym21
2026-03-19 18:16:45 +01:00
parent 8910c0988e
commit 45de61b438
30 changed files with 1387 additions and 1392 deletions

View File

@@ -11,7 +11,7 @@ use vecdb::{
use crate::{
distribution::state::{CohortState, CostBasisOps, RealizedOps},
internal::{
AmountPerBlockCumulativeWithSums, FiatPerBlockCumulativeWithSums,
FiatPerBlockCumulativeWithSums,
FiatPerBlockWithDeltas, Identity, LazyPerBlock, PriceWithRatioPerBlock,
},
prices,
@@ -26,8 +26,6 @@ pub struct RealizedMinimal<M: StorageMode = Rw> {
pub loss: FiatPerBlockCumulativeWithSums<Cents, M>,
pub price: PriceWithRatioPerBlock<M>,
pub mvrv: LazyPerBlock<StoredF32>,
pub transfer_volume: AmountPerBlockCumulativeWithSums<M>,
}
impl RealizedMinimal {
@@ -50,21 +48,12 @@ impl RealizedMinimal {
&price.ratio,
);
let transfer_volume = AmountPerBlockCumulativeWithSums::forced_import(
cfg.db,
&cfg.name("transfer_volume"),
cfg.version,
cfg.indexes,
cfg.cached_starts,
)?;
Ok(Self {
cap,
profit: cfg.import("realized_profit", v1)?,
loss: cfg.import("realized_loss", v1)?,
price,
mvrv,
transfer_volume,
})
}
@@ -75,7 +64,6 @@ impl RealizedMinimal {
.len()
.min(self.profit.base.cents.height.len())
.min(self.loss.base.cents.height.len())
.min(self.transfer_volume.base.sats.height.len())
}
#[inline(always)]
@@ -83,7 +71,6 @@ impl RealizedMinimal {
self.cap.cents.height.push(state.realized.cap());
self.profit.base.cents.height.push(state.realized.profit());
self.loss.base.cents.height.push(state.realized.loss());
self.transfer_volume.base.sats.height.push(state.sent);
}
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
@@ -91,7 +78,6 @@ impl RealizedMinimal {
&mut self.cap.cents.height as &mut dyn AnyStoredVec,
&mut self.profit.base.cents.height,
&mut self.loss.base.cents.height,
&mut self.transfer_volume.base.sats.height,
]
}
@@ -104,20 +90,16 @@ impl RealizedMinimal {
sum_others!(self, starting_indexes, others, exit; cap.cents.height);
sum_others!(self, starting_indexes, others, exit; profit.base.cents.height);
sum_others!(self, starting_indexes, others, exit; loss.base.cents.height);
sum_others!(self, starting_indexes, others, exit; transfer_volume.base.sats.height);
Ok(())
}
pub(crate) fn compute_rest_part1(
&mut self,
prices: &prices::Vecs,
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
self.profit.compute_rest(starting_indexes.height, exit)?;
self.loss.compute_rest(starting_indexes.height, exit)?;
self.transfer_volume
.compute_rest(starting_indexes.height, prices, exit)?;
Ok(())
}