global: snapshot

This commit is contained in:
nym21
2026-03-07 11:42:11 +01:00
parent 5a73f1a88e
commit bf07570848
31 changed files with 1151 additions and 1009 deletions

View File

@@ -32,8 +32,8 @@ impl Vecs {
self.hashrate.compute(
&blocks.count,
&blocks.difficulty,
&self.rewards.coinbase.rolling._24h.sum.sats.height,
&self.rewards.coinbase.rolling._24h.sum.usd.height,
&self.rewards.coinbase.sum._24h.sats.height,
&self.rewards.coinbase.sum._24h.usd.height,
starting_indexes,
exit,
)?;

View File

@@ -76,29 +76,21 @@ impl Vecs {
},
)?;
self.subsidy.compute(
self.subsidy.base.sats.height.compute_transform2(
starting_indexes.height,
&window_starts,
prices,
exit,
|vec| {
vec.compute_transform2(
starting_indexes.height,
&self.coinbase.base.sats.height,
&self.fees.base.sats.height,
|(height, coinbase, fees, ..)| {
(
height,
coinbase.checked_sub(fees).unwrap_or_else(|| {
panic!("coinbase {coinbase:?} < fees {fees:?} at {height:?}")
}),
)
},
exit,
)?;
Ok(())
&self.coinbase.base.sats.height,
&self.fees.base.sats.height,
|(height, coinbase, fees, ..)| {
(
height,
coinbase.checked_sub(fees).unwrap_or_else(|| {
panic!("coinbase {coinbase:?} < fees {fees:?} at {height:?}")
}),
)
},
exit,
)?;
self.subsidy.compute(prices, starting_indexes.height, exit)?;
self.unclaimed_rewards.compute(
starting_indexes.height,
@@ -135,12 +127,12 @@ impl Vecs {
.as_mut_array()
.into_iter()
.zip(self.fees.rolling.as_array())
.zip(self.coinbase.rolling.as_array())
.zip(self.coinbase.sum.as_array())
{
fee_dom.compute_binary::<Sats, Sats, RatioSatsBp16>(
starting_indexes.height,
&fees_w.sum.sats.height,
&coinbase_w.sum.sats.height,
&coinbase_w.sats.height,
exit,
)?;
}

View File

@@ -6,8 +6,8 @@ use super::Vecs;
use crate::{
indexes,
internal::{
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulativeSum,
ValueFromHeightFull,
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulative,
ValueFromHeightCumulativeSum, ValueFromHeightFull,
},
};
@@ -18,8 +18,8 @@ impl Vecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
coinbase: ValueFromHeightFull::forced_import(db, "coinbase", version, indexes)?,
subsidy: ValueFromHeightFull::forced_import(db, "subsidy", version, indexes)?,
coinbase: ValueFromHeightCumulativeSum::forced_import(db, "coinbase", version, indexes)?,
subsidy: ValueFromHeightCumulative::forced_import(db, "subsidy", version, indexes)?,
fees: ValueFromHeightFull::forced_import(db, "fees", version, indexes)?,
unclaimed_rewards: ValueFromHeightCumulativeSum::forced_import(
db,

View File

@@ -3,14 +3,14 @@ use brk_types::{BasisPoints16, Cents};
use vecdb::{Rw, StorageMode};
use crate::internal::{
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulativeSum,
ValueFromHeightFull,
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulative,
ValueFromHeightCumulativeSum, ValueFromHeightFull,
};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub coinbase: ValueFromHeightFull<M>,
pub subsidy: ValueFromHeightFull<M>,
pub coinbase: ValueFromHeightCumulativeSum<M>,
pub subsidy: ValueFromHeightCumulative<M>,
pub fees: ValueFromHeightFull<M>,
pub unclaimed_rewards: ValueFromHeightCumulativeSum<M>,
pub fee_dominance: PercentFromHeight<BasisPoints16, M>,