global: big snapshot

This commit is contained in:
nym21
2026-03-13 12:47:01 +01:00
parent c83955eea7
commit 2b31c7f6b7
158 changed files with 4961 additions and 6939 deletions

View File

@@ -5,7 +5,7 @@ use brk_types::Version;
use crate::{
indexes,
internal::{finalize_db, open_db},
internal::{finalize_db, open_db, CachedWindowStarts},
};
use super::{HashrateVecs, RewardsVecs, Vecs};
@@ -15,11 +15,12 @@ impl Vecs {
parent_path: &Path,
parent_version: Version,
indexes: &indexes::Vecs,
cached_starts: &CachedWindowStarts,
) -> Result<Self> {
let db = open_db(parent_path, super::DB_NAME, 50_000_000)?;
let version = parent_version;
let rewards = RewardsVecs::forced_import(&db, version, indexes)?;
let rewards = RewardsVecs::forced_import(&db, version, indexes, cached_starts)?;
let hashrate = HashrateVecs::forced_import(&db, version, indexes)?;
let this = Self {

View File

@@ -18,11 +18,8 @@ impl Vecs {
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
let window_starts = lookback.window_starts();
self.coinbase.compute(
starting_indexes.height,
&window_starts,
prices,
exit,
|vec| {
@@ -59,6 +56,8 @@ impl Vecs {
)?;
// Coinbase fee is 0, so including it in the sum doesn't affect the result
let window_starts = lookback.window_starts();
self.fees.compute(
starting_indexes.height,
&window_starts,
@@ -78,7 +77,7 @@ impl Vecs {
self.subsidy.base.sats.height.compute_transform2(
starting_indexes.height,
&self.coinbase.base.sats.height,
&self.coinbase.raw.sats.height,
&self.fees.base.sats.height,
|(height, coinbase, fees, ..)| {
(
@@ -94,7 +93,6 @@ impl Vecs {
self.unclaimed.compute(
starting_indexes.height,
&window_starts,
prices,
exit,
|vec| {
@@ -125,7 +123,7 @@ impl Vecs {
self.fee_dominance_rolling
.compute_binary::<Sats, Sats, RatioSatsBp16, _, _>(
starting_indexes.height,
self.fees.rolling.as_array().map(|w| &w.sum.sats.height),
self.fees.sum.as_array().map(|w| &w.sats.height),
self.coinbase.sum.as_array().map(|w| &w.sats.height),
exit,
)?;
@@ -166,7 +164,7 @@ impl Vecs {
.compute_binary::<Dollars, Dollars, RatioDollarsBp32, _, _>(
starting_indexes.height,
self.coinbase.sum.as_array().map(|w| &w.usd.height),
self.fees.rolling.as_array().map(|w| &w.sum.usd.height),
self.fees.sum.as_array().map(|w| &w.usd.height),
exit,
)?;

View File

@@ -6,8 +6,9 @@ use super::Vecs;
use crate::{
indexes,
internal::{
AmountPerBlockCumulative, AmountPerBlockCumulativeSum, AmountPerBlockFull,
FiatPerBlock, PercentPerBlock, PercentRollingWindows, RatioRollingWindows,
AmountPerBlockCumulative, AmountPerBlockCumulativeWithSums, AmountPerBlockFull,
CachedWindowStarts, FiatPerBlock, PercentPerBlock, PercentRollingWindows,
RatioRollingWindows,
},
};
@@ -16,18 +17,20 @@ impl Vecs {
db: &Database,
version: Version,
indexes: &indexes::Vecs,
cached_starts: &CachedWindowStarts,
) -> Result<Self> {
Ok(Self {
coinbase: AmountPerBlockCumulativeSum::forced_import(
db, "coinbase", version, indexes,
coinbase: AmountPerBlockCumulativeWithSums::forced_import(
db, "coinbase", version, indexes, cached_starts,
)?,
subsidy: AmountPerBlockCumulative::forced_import(db, "subsidy", version, indexes)?,
fees: AmountPerBlockFull::forced_import(db, "fees", version, indexes)?,
unclaimed: AmountPerBlockCumulativeSum::forced_import(
fees: AmountPerBlockFull::forced_import(db, "fees", version, indexes, cached_starts)?,
unclaimed: AmountPerBlockCumulativeWithSums::forced_import(
db,
"unclaimed_rewards",
version,
indexes,
cached_starts,
)?,
fee_dominance: PercentPerBlock::forced_import(db, "fee_dominance", version, indexes)?,
fee_dominance_rolling: PercentRollingWindows::forced_import(

View File

@@ -3,16 +3,16 @@ use brk_types::{BasisPoints16, BasisPoints32, Cents};
use vecdb::{Rw, StorageMode};
use crate::internal::{
AmountPerBlockCumulative, AmountPerBlockCumulativeSum, AmountPerBlockFull,
AmountPerBlockCumulative, AmountPerBlockCumulativeWithSums, AmountPerBlockFull,
FiatPerBlock, PercentPerBlock, PercentRollingWindows, RatioRollingWindows,
};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub coinbase: AmountPerBlockCumulativeSum<M>,
pub coinbase: AmountPerBlockCumulativeWithSums<M>,
pub subsidy: AmountPerBlockCumulative<M>,
pub fees: AmountPerBlockFull<M>,
pub unclaimed: AmountPerBlockCumulativeSum<M>,
pub unclaimed: AmountPerBlockCumulativeWithSums<M>,
#[traversable(wrap = "fees", rename = "dominance")]
pub fee_dominance: PercentPerBlock<BasisPoints16, M>,
#[traversable(wrap = "fees", rename = "dominance")]