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

@@ -3,7 +3,7 @@ use brk_types::Version;
use vecdb::Database;
use super::Vecs;
use crate::{indexes, internal::ComputedFromHeightDistribution};
use crate::{indexes, internal::ComputedFromHeightRollingAverage};
impl Vecs {
pub(crate) fn forced_import(
@@ -11,8 +11,12 @@ impl Vecs {
version: Version,
indexes: &indexes::Vecs,
) -> Result<Self> {
let interval =
ComputedFromHeightDistribution::forced_import(db, "block_interval", version, indexes)?;
let interval = ComputedFromHeightRollingAverage::forced_import(
db,
"block_interval",
version,
indexes,
)?;
Ok(Self(interval))
}

View File

@@ -4,9 +4,9 @@ use brk_traversable::Traversable;
use brk_types::Timestamp;
use vecdb::{Rw, StorageMode};
use crate::internal::ComputedFromHeightDistribution;
use crate::internal::ComputedFromHeightRollingAverage;
#[derive(Deref, DerefMut, Traversable)]
pub struct Vecs<M: StorageMode = Rw>(
#[traversable(flatten)] pub ComputedFromHeightDistribution<Timestamp, M>,
#[traversable(flatten)] pub ComputedFromHeightRollingAverage<Timestamp, M>,
);

View File

@@ -5,7 +5,7 @@ use vecdb::Database;
use super::Vecs;
use crate::{
indexes,
internal::{ComputedHeightDerivedFull, PercentFromHeightDistribution},
internal::{ComputedHeightDerivedFull, PercentFromHeightRollingAverage},
};
impl Vecs {
@@ -17,8 +17,12 @@ impl Vecs {
let weight =
ComputedHeightDerivedFull::forced_import(db, "block_weight", version, indexes)?;
let fullness =
PercentFromHeightDistribution::forced_import(db, "block_fullness", version, indexes)?;
let fullness = PercentFromHeightRollingAverage::forced_import(
db,
"block_fullness",
version,
indexes,
)?;
Ok(Self { weight, fullness })
}

View File

@@ -2,10 +2,10 @@ use brk_traversable::Traversable;
use brk_types::{BasisPoints16, Weight};
use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedHeightDerivedFull, PercentFromHeightDistribution};
use crate::internal::{ComputedHeightDerivedFull, PercentFromHeightRollingAverage};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub weight: ComputedHeightDerivedFull<Weight, M>,
pub fullness: PercentFromHeightDistribution<BasisPoints16, M>,
pub fullness: PercentFromHeightRollingAverage<BasisPoints16, M>,
}