global: snapshot

This commit is contained in:
nym21
2026-03-13 16:27:10 +01:00
parent b2a1251774
commit 3709ceff8e
168 changed files with 2007 additions and 2008 deletions
@@ -1,5 +1,5 @@
use brk_error::Result;
use brk_types::{Bitcoin, CheckedSub, Indexes, StoredF64};
use brk_types::{Bitcoin, Indexes, StoredF64};
use vecdb::Exit;
use super::Vecs;
@@ -30,8 +30,8 @@ impl Vecs {
.compute(starting_indexes.height, exit, |vec| {
vec.compute_subtract(
starting_indexes.height,
&self.coinblocks_created.raw.height,
&distribution.coinblocks_destroyed.raw.height,
&self.coinblocks_created.base.height,
&distribution.coinblocks_destroyed.base.height,
exit,
)?;
Ok(())
@@ -44,13 +44,6 @@ impl Vecs {
exit,
)?;
self.vaultedness.height.compute_transform(
starting_indexes.height,
&self.liveliness.height,
|(i, v, ..)| (i, StoredF64::from(1.0).checked_sub(v).unwrap()),
exit,
)?;
self.ratio.height.compute_divide(
starting_indexes.height,
&self.liveliness.height,
@@ -1,11 +1,13 @@
use brk_error::Result;
use brk_types::Version;
use vecdb::Database;
use vecdb::{Database, ReadableCloneableVec};
use super::Vecs;
use crate::{
indexes,
internal::{CachedWindowStarts, ComputedPerBlock, ComputedPerBlockCumulativeWithSums},
internal::{
CachedWindowStarts, LazyPerBlock, OneMinusF64, PerBlock, PerBlockCumulativeWithSums,
},
};
impl Vecs {
@@ -15,29 +17,25 @@ impl Vecs {
indexes: &indexes::Vecs,
cached_starts: &CachedWindowStarts,
) -> Result<Self> {
let liveliness = PerBlock::forced_import(db, "liveliness", version, indexes)?;
let vaultedness = LazyPerBlock::from_computed::<OneMinusF64>(
"vaultedness",
version,
liveliness.height.read_only_boxed_clone(),
&liveliness,
);
Ok(Self {
coinblocks_created: ComputedPerBlockCumulativeWithSums::forced_import(
db,
"coinblocks_created",
version,
indexes,
cached_starts,
coinblocks_created: PerBlockCumulativeWithSums::forced_import(
db, "coinblocks_created", version, indexes, cached_starts,
)?,
coinblocks_stored: ComputedPerBlockCumulativeWithSums::forced_import(
db,
"coinblocks_stored",
version,
indexes,
cached_starts,
)?,
liveliness: ComputedPerBlock::forced_import(db, "liveliness", version, indexes)?,
vaultedness: ComputedPerBlock::forced_import(db, "vaultedness", version, indexes)?,
ratio: ComputedPerBlock::forced_import(
db,
"activity_to_vaultedness_ratio",
version,
indexes,
coinblocks_stored: PerBlockCumulativeWithSums::forced_import(
db, "coinblocks_stored", version, indexes, cached_starts,
)?,
liveliness,
vaultedness,
ratio: PerBlock::forced_import(db, "activity_to_vaultedness_ratio", version, indexes)?,
})
}
}
@@ -2,13 +2,13 @@ use brk_traversable::Traversable;
use brk_types::StoredF64;
use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedPerBlock, ComputedPerBlockCumulativeWithSums};
use crate::internal::{LazyPerBlock, PerBlock, PerBlockCumulativeWithSums};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub coinblocks_created: ComputedPerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
pub coinblocks_stored: ComputedPerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
pub liveliness: ComputedPerBlock<StoredF64, M>,
pub vaultedness: ComputedPerBlock<StoredF64, M>,
pub ratio: ComputedPerBlock<StoredF64, M>,
pub coinblocks_created: PerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
pub coinblocks_stored: PerBlockCumulativeWithSums<StoredF64, StoredF64, M>,
pub liveliness: PerBlock<StoredF64, M>,
pub vaultedness: LazyPerBlock<StoredF64>,
pub ratio: PerBlock<StoredF64, M>,
}