global: snapshot

This commit is contained in:
nym21
2026-03-16 18:38:16 +01:00
parent ae067739ce
commit 5848d25612
55 changed files with 1366 additions and 1384 deletions

View File

@@ -28,7 +28,7 @@ impl Vecs {
exit,
)?;
self.blocks_before_next.height.compute_transform(
self.blocks_to_retarget.height.compute_transform(
starting_indexes.height,
&indexes.height.identity,
|(h, ..)| (h, StoredU32::from(h.left_before_next_diff_adj())),

View File

@@ -20,25 +20,25 @@ impl Vecs {
) -> Result<Self> {
let v2 = Version::TWO;
let as_hash = LazyPerBlock::from_height_source::<DifficultyToHashF64>(
"difficulty_as_hash",
let hashrate = LazyPerBlock::from_height_source::<DifficultyToHashF64>(
"difficulty_hashrate",
version,
indexer.vecs.blocks.difficulty.read_only_boxed_clone(),
indexes,
);
let blocks_before_next = PerBlock::forced_import(
let blocks_to_retarget = PerBlock::forced_import(
db,
"blocks_before_next_difficulty_adjustment",
"blocks_to_retarget",
version + v2,
indexes,
)?;
let days_before_next = LazyPerBlock::from_computed::<BlocksToDaysF32>(
"days_before_next_difficulty_adjustment",
let days_to_retarget = LazyPerBlock::from_computed::<BlocksToDaysF32>(
"days_to_retarget",
version + v2,
blocks_before_next.height.read_only_boxed_clone(),
&blocks_before_next,
blocks_to_retarget.height.read_only_boxed_clone(),
&blocks_to_retarget,
);
Ok(Self {
@@ -48,7 +48,7 @@ impl Vecs {
version,
indexes,
),
as_hash,
hashrate,
adjustment: PercentPerBlock::forced_import(
db,
"difficulty_adjustment",
@@ -56,8 +56,8 @@ impl Vecs {
indexes,
)?,
epoch: PerBlock::forced_import(db, "difficulty_epoch", version, indexes)?,
blocks_before_next,
days_before_next,
blocks_to_retarget,
days_to_retarget,
})
}
}

View File

@@ -6,9 +6,9 @@ use crate::internal::{LazyPerBlock, PerBlock, Resolutions, PercentPerBlock};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub value: Resolutions<StoredF64>,
pub as_hash: LazyPerBlock<StoredF64>,
pub hashrate: LazyPerBlock<StoredF64>,
pub adjustment: PercentPerBlock<BasisPointsSigned32, M>,
pub epoch: PerBlock<Epoch, M>,
pub blocks_before_next: PerBlock<StoredU32, M>,
pub days_before_next: LazyPerBlock<StoredF32, StoredU32>,
pub blocks_to_retarget: PerBlock<StoredU32, M>,
pub days_to_retarget: LazyPerBlock<StoredF32, StoredU32>,
}

View File

@@ -19,7 +19,7 @@ impl Vecs {
exit,
)?;
self.blocks_before_next.height.compute_transform(
self.blocks_to_halving.height.compute_transform(
starting_indexes.height,
&indexes.height.identity,
|(h, ..)| (h, StoredU32::from(h.left_before_next_halving())),

View File

@@ -16,21 +16,21 @@ impl Vecs {
) -> Result<Self> {
let v2 = Version::TWO;
let blocks_before_next = PerBlock::forced_import(
db, "blocks_before_next_halving", version + v2, indexes,
let blocks_to_halving = PerBlock::forced_import(
db, "blocks_to_halving", version + v2, indexes,
)?;
let days_before_next = LazyPerBlock::from_computed::<BlocksToDaysF32>(
"days_before_next_halving",
let days_to_halving = LazyPerBlock::from_computed::<BlocksToDaysF32>(
"days_to_halving",
version + v2,
blocks_before_next.height.read_only_boxed_clone(),
&blocks_before_next,
blocks_to_halving.height.read_only_boxed_clone(),
&blocks_to_halving,
);
Ok(Self {
epoch: PerBlock::forced_import(db, "halving_epoch", version, indexes)?,
blocks_before_next,
days_before_next,
blocks_to_halving,
days_to_halving,
})
}
}

View File

@@ -6,6 +6,6 @@ use crate::internal::{LazyPerBlock, PerBlock};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub epoch: PerBlock<Halving, M>,
pub blocks_before_next: PerBlock<StoredU32, M>,
pub days_before_next: LazyPerBlock<StoredF32, StoredU32>,
pub blocks_to_halving: PerBlock<StoredU32, M>,
pub days_to_halving: LazyPerBlock<StoredF32, StoredU32>,
}