global: snapshot

This commit is contained in:
nym21
2026-03-01 22:41:25 +01:00
parent 159c983a3f
commit 7cb1bfa667
119 changed files with 1241 additions and 1182 deletions

View File

@@ -6,7 +6,7 @@ use vecdb::{Database, ReadableCloneableVec};
use super::Vecs;
use crate::{
indexes,
internal::{ComputedFromHeightLast, ComputedHeightDerivedLast},
internal::{ComputedFromHeight, ComputedHeightDerived},
};
impl Vecs {
@@ -19,22 +19,22 @@ impl Vecs {
let v2 = Version::TWO;
Ok(Self {
raw: ComputedHeightDerivedLast::forced_import(
raw: ComputedHeightDerived::forced_import(
"difficulty",
indexer.vecs.blocks.difficulty.read_only_boxed_clone(),
version,
indexes,
),
as_hash: ComputedFromHeightLast::forced_import(db, "difficulty_as_hash", version, indexes)?,
adjustment: ComputedFromHeightLast::forced_import(db, "difficulty_adjustment", version, indexes)?,
epoch: ComputedFromHeightLast::forced_import(db, "difficulty_epoch", version, indexes)?,
blocks_before_next_adjustment: ComputedFromHeightLast::forced_import(
as_hash: ComputedFromHeight::forced_import(db, "difficulty_as_hash", version, indexes)?,
adjustment: ComputedFromHeight::forced_import(db, "difficulty_adjustment", version, indexes)?,
epoch: ComputedFromHeight::forced_import(db, "difficulty_epoch", version, indexes)?,
blocks_before_next_adjustment: ComputedFromHeight::forced_import(
db,
"blocks_before_next_difficulty_adjustment",
version + v2,
indexes,
)?,
days_before_next_adjustment: ComputedFromHeightLast::forced_import(
days_before_next_adjustment: ComputedFromHeight::forced_import(
db,
"days_before_next_difficulty_adjustment",
version + v2,

View File

@@ -2,15 +2,15 @@ use brk_traversable::Traversable;
use brk_types::{DifficultyEpoch, StoredF32, StoredF64, StoredU32};
use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedFromHeightLast, ComputedHeightDerivedLast};
use crate::internal::{ComputedFromHeight, ComputedHeightDerived};
/// Difficulty metrics: raw difficulty, derived stats, adjustment, and countdown
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub raw: ComputedHeightDerivedLast<StoredF64>,
pub as_hash: ComputedFromHeightLast<StoredF32, M>,
pub adjustment: ComputedFromHeightLast<StoredF32, M>,
pub epoch: ComputedFromHeightLast<DifficultyEpoch, M>,
pub blocks_before_next_adjustment: ComputedFromHeightLast<StoredU32, M>,
pub days_before_next_adjustment: ComputedFromHeightLast<StoredF32, M>,
pub raw: ComputedHeightDerived<StoredF64>,
pub as_hash: ComputedFromHeight<StoredF32, M>,
pub adjustment: ComputedFromHeight<StoredF32, M>,
pub epoch: ComputedFromHeight<DifficultyEpoch, M>,
pub blocks_before_next_adjustment: ComputedFromHeight<StoredU32, M>,
pub days_before_next_adjustment: ComputedFromHeight<StoredF32, M>,
}

View File

@@ -3,7 +3,7 @@ use brk_types::Version;
use vecdb::Database;
use super::Vecs;
use crate::{indexes, internal::ComputedFromHeightLast};
use crate::{indexes, internal::ComputedFromHeight};
impl Vecs {
pub(crate) fn forced_import(
@@ -14,14 +14,14 @@ impl Vecs {
let v2 = Version::TWO;
Ok(Self {
epoch: ComputedFromHeightLast::forced_import(db, "halving_epoch", version, indexes)?,
blocks_before_next_halving: ComputedFromHeightLast::forced_import(
epoch: ComputedFromHeight::forced_import(db, "halving_epoch", version, indexes)?,
blocks_before_next_halving: ComputedFromHeight::forced_import(
db,
"blocks_before_next_halving",
version + v2,
indexes,
)?,
days_before_next_halving: ComputedFromHeightLast::forced_import(
days_before_next_halving: ComputedFromHeight::forced_import(
db,
"days_before_next_halving",
version + v2,

View File

@@ -2,12 +2,12 @@ use brk_traversable::Traversable;
use brk_types::{HalvingEpoch, StoredF32, StoredU32};
use vecdb::{Rw, StorageMode};
use crate::internal::ComputedFromHeightLast;
use crate::internal::ComputedFromHeight;
/// Halving epoch metrics and countdown
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub epoch: ComputedFromHeightLast<HalvingEpoch, M>,
pub blocks_before_next_halving: ComputedFromHeightLast<StoredU32, M>,
pub days_before_next_halving: ComputedFromHeightLast<StoredF32, M>,
pub epoch: ComputedFromHeight<HalvingEpoch, M>,
pub blocks_before_next_halving: ComputedFromHeight<StoredU32, M>,
pub days_before_next_halving: ComputedFromHeight<StoredF32, M>,
}

View File

@@ -5,7 +5,7 @@ use vecdb::Database;
use super::Vecs;
use crate::{
indexes,
internal::{ComputedFromHeightCumulativeFull, ComputedHeightDerivedCumulativeFull},
internal::{ComputedFromHeightFull, ComputedHeightDerivedFull},
};
impl Vecs {
@@ -15,13 +15,13 @@ impl Vecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
vbytes: ComputedFromHeightCumulativeFull::forced_import(
vbytes: ComputedFromHeightFull::forced_import(
db,
"block_vbytes",
version,
indexes,
)?,
size: ComputedHeightDerivedCumulativeFull::forced_import(
size: ComputedHeightDerivedFull::forced_import(
db,
"block_size",
version,

View File

@@ -2,10 +2,10 @@ use brk_traversable::Traversable;
use brk_types::StoredU64;
use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedFromHeightCumulativeFull, ComputedHeightDerivedCumulativeFull};
use crate::internal::{ComputedFromHeightFull, ComputedHeightDerivedFull};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub vbytes: ComputedFromHeightCumulativeFull<StoredU64, M>,
pub size: ComputedHeightDerivedCumulativeFull<StoredU64, M>,
pub vbytes: ComputedFromHeightFull<StoredU64, M>,
pub size: ComputedHeightDerivedFull<StoredU64, M>,
}

View File

@@ -5,7 +5,7 @@ use vecdb::Database;
use super::Vecs;
use crate::{
indexes,
internal::{ComputedFromHeightDistribution, ComputedHeightDerivedCumulativeFull},
internal::{ComputedFromHeightDistribution, ComputedHeightDerivedFull},
};
impl Vecs {
@@ -14,7 +14,7 @@ impl Vecs {
version: Version,
indexes: &indexes::Vecs,
) -> Result<Self> {
let weight = ComputedHeightDerivedCumulativeFull::forced_import(
let weight = ComputedHeightDerivedFull::forced_import(
db,
"block_weight",
version,

View File

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