global: snapshot part 13

This commit is contained in:
nym21
2026-03-21 13:25:06 +01:00
parent 485f118a5f
commit 1ed4f258b4
13 changed files with 918 additions and 12813 deletions

View File

@@ -52,7 +52,7 @@ impl RealizedCore {
let minimal = RealizedMinimal::forced_import(cfg)?;
let neg_loss_base = LazyPerBlock::from_height_source::<NegCentsUnsignedToDollars>(
&cfg.name("neg_realized_loss"),
&cfg.name("realized_loss_neg"),
cfg.version + Version::ONE,
minimal.loss.block.cents.read_only_boxed_clone(),
cfg.indexes,
@@ -60,7 +60,7 @@ impl RealizedCore {
let neg_loss_sum = minimal.loss.sum.0.map_with_suffix(|suffix, slot| {
LazyPerBlock::from_height_source::<NegCentsUnsignedToDollars>(
&cfg.name(&format!("neg_realized_loss_sum_{suffix}")),
&cfg.name(&format!("realized_loss_neg_sum_{suffix}")),
cfg.version + Version::ONE,
slot.cents.height.read_only_boxed_clone(),
cfg.indexes,

View File

@@ -6,8 +6,7 @@ use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec};
use crate::{distribution::state::{CohortState, CostBasisOps, RealizedOps}, prices};
use crate::internal::{
AmountPerBlock, HalveCents, HalveDollars, HalveSats, HalveSatsToBitcoin,
LazyAmountPerBlock, LazyRollingDeltasFromHeight,
AmountPerBlock, LazyRollingDeltasFromHeight,
};
use crate::distribution::metrics::ImportConfig;
@@ -16,20 +15,12 @@ use crate::distribution::metrics::ImportConfig;
#[derive(Traversable)]
pub struct SupplyBase<M: StorageMode = Rw> {
pub total: AmountPerBlock<M>,
pub half: LazyAmountPerBlock,
pub delta: LazyRollingDeltasFromHeight<Sats, SatsSigned, BasisPointsSigned32>,
}
impl SupplyBase {
pub(crate) fn forced_import(cfg: &ImportConfig) -> Result<Self> {
let supply = cfg.import("supply", Version::ZERO)?;
let supply_half = LazyAmountPerBlock::from_block_source::<
HalveSats,
HalveSatsToBitcoin,
HalveCents,
HalveDollars,
>(&cfg.name("supply_half"), &supply, cfg.version);
let supply: AmountPerBlock = cfg.import("supply", Version::ZERO)?;
let delta = LazyRollingDeltasFromHeight::new(
&cfg.name("supply_delta"),
@@ -41,7 +32,6 @@ impl SupplyBase {
Ok(Self {
total: supply,
half: supply_half,
delta,
})
}

View File

@@ -6,7 +6,9 @@ use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec};
use crate::{distribution::state::UnrealizedState, prices};
use crate::internal::AmountPerBlock;
use crate::internal::{
AmountPerBlock, HalveCents, HalveDollars, HalveSats, HalveSatsToBitcoin, LazyAmountPerBlock,
};
use crate::distribution::metrics::ImportConfig;
@@ -20,6 +22,7 @@ pub struct SupplyCore<M: StorageMode = Rw> {
#[traversable(flatten)]
pub base: SupplyBase<M>,
pub half: LazyAmountPerBlock,
pub in_profit: AmountPerBlock<M>,
pub in_loss: AmountPerBlock<M>,
}
@@ -29,8 +32,16 @@ impl SupplyCore {
let v0 = Version::ZERO;
let base = SupplyBase::forced_import(cfg)?;
let half = LazyAmountPerBlock::from_block_source::<
HalveSats,
HalveSatsToBitcoin,
HalveCents,
HalveDollars,
>(&cfg.name("supply_half"), &base.total, cfg.version);
Ok(Self {
base,
half,
in_profit: cfg.import("supply_in_profit", v0)?,
in_loss: cfg.import("supply_in_loss", v0)?,
})

View File

@@ -30,7 +30,7 @@ impl UnrealizedBasic {
let loss: FiatPerBlock<Cents> = cfg.import("unrealized_loss", v1)?;
let neg_loss = LazyPerBlock::from_computed::<NegCentsUnsignedToDollars>(
&cfg.name("neg_unrealized_loss"),
&cfg.name("unrealized_loss_neg"),
cfg.version,
loss.cents.height.read_only_boxed_clone(),
&loss.cents,