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
@@ -3,24 +3,19 @@ use brk_types::{Height, Indexes, Sats};
use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, VecIndex, WritableVec};
use super::Vecs;
use crate::{blocks, mining, prices, scripts};
use crate::{mining, prices, scripts};
impl Vecs {
pub(crate) fn compute(
&mut self,
scripts: &scripts::Vecs,
mining: &mining::Vecs,
lookback: &blocks::LookbackVecs,
prices: &prices::Vecs,
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
let window_starts = lookback.window_starts();
// 1. Compute opreturn supply - copy per-block opreturn values from scripts
self.opreturn.compute(
starting_indexes.height,
&window_starts,
prices,
exit,
|height_vec| {
@@ -59,12 +54,11 @@ impl Vecs {
// 2. Compute unspendable supply = opreturn + unclaimed_rewards + genesis (at height 0)
// Get reference to opreturn height vec for computing unspendable
let opreturn_height = &self.opreturn.base.sats.height;
let unclaimed_height = &mining.rewards.unclaimed.base.sats.height;
let opreturn_height = &self.opreturn.raw.sats.height;
let unclaimed_height = &mining.rewards.unclaimed.raw.sats.height;
self.unspendable.compute(
starting_indexes.height,
&window_starts,
prices,
exit,
|height_vec| {
@@ -3,26 +3,29 @@ use brk_types::Version;
use vecdb::Database;
use super::Vecs;
use crate::{indexes, internal::AmountPerBlockCumulativeSum};
use crate::{indexes, internal::{AmountPerBlockCumulativeWithSums, CachedWindowStarts}};
impl Vecs {
pub(crate) fn forced_import(
db: &Database,
version: Version,
indexes: &indexes::Vecs,
cached_starts: &CachedWindowStarts,
) -> Result<Self> {
Ok(Self {
opreturn: AmountPerBlockCumulativeSum::forced_import(
opreturn: AmountPerBlockCumulativeWithSums::forced_import(
db,
"opreturn_supply",
version,
indexes,
cached_starts,
)?,
unspendable: AmountPerBlockCumulativeSum::forced_import(
unspendable: AmountPerBlockCumulativeWithSums::forced_import(
db,
"unspendable_supply",
version,
indexes,
cached_starts,
)?,
})
}
@@ -1,10 +1,10 @@
use brk_traversable::Traversable;
use vecdb::{Rw, StorageMode};
use crate::internal::AmountPerBlockCumulativeSum;
use crate::internal::AmountPerBlockCumulativeWithSums;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub opreturn: AmountPerBlockCumulativeSum<M>,
pub unspendable: AmountPerBlockCumulativeSum<M>,
pub opreturn: AmountPerBlockCumulativeWithSums<M>,
pub unspendable: AmountPerBlockCumulativeWithSums<M>,
}