global: big snapshot

This commit is contained in:
nym21
2026-01-09 20:00:20 +01:00
parent cb0abc324e
commit 426d7797a3
442 changed files with 17952 additions and 20071 deletions
@@ -2,9 +2,9 @@ use brk_error::Result;
use brk_types::StoredU32;
use vecdb::{Exit, TypedVecIterator};
use super::Vecs;
use super::super::TARGET_BLOCKS_PER_DAY_F32;
use crate::{indexes, ComputeIndexes};
use super::Vecs;
use crate::{ComputeIndexes, indexes};
impl Vecs {
pub fn compute(
@@ -14,12 +14,13 @@ impl Vecs {
exit: &Exit,
) -> Result<()> {
let mut height_to_difficultyepoch_iter =
indexes.block.height_to_difficultyepoch.into_iter();
self.indexes_to_difficultyepoch.compute_all(starting_indexes, exit, |vec| {
let mut height_count_iter = indexes.time.dateindex_to_height_count.into_iter();
indexes.height.difficultyepoch.into_iter();
self.difficultyepoch
.compute_all(starting_indexes, exit, |vec| {
let mut height_count_iter = indexes.dateindex.height_count.into_iter();
vec.compute_transform(
starting_indexes.dateindex,
&indexes.time.dateindex_to_first_height,
&indexes.dateindex.first_height,
|(di, height, ..)| {
(
di,
@@ -32,27 +33,35 @@ impl Vecs {
Ok(())
})?;
self.indexes_to_blocks_before_next_difficulty_adjustment
.compute_all(indexes, starting_indexes, exit, |v| {
self.blocks_before_next_difficulty_adjustment.compute_all(
indexes,
starting_indexes,
exit,
|v| {
v.compute_transform(
starting_indexes.height,
&indexes.block.height_to_height,
&indexes.height.identity,
|(h, ..)| (h, StoredU32::from(h.left_before_next_diff_adj())),
exit,
)?;
Ok(())
})?;
},
)?;
self.indexes_to_days_before_next_difficulty_adjustment
.compute_all(indexes, starting_indexes, exit, |v| {
self.days_before_next_difficulty_adjustment.compute_all(
indexes,
starting_indexes,
exit,
|v| {
v.compute_transform(
starting_indexes.height,
&self.indexes_to_blocks_before_next_difficulty_adjustment.height,
&self.blocks_before_next_difficulty_adjustment.height,
|(h, blocks, ..)| (h, (*blocks as f32 / TARGET_BLOCKS_PER_DAY_F32).into()),
exit,
)?;
Ok(())
})?;
},
)?;
Ok(())
}
@@ -13,19 +13,19 @@ impl Vecs {
let v2 = Version::TWO;
Ok(Self {
indexes_to_difficultyepoch: ComputedDateLast::forced_import(
difficultyepoch: ComputedDateLast::forced_import(
db,
"difficultyepoch",
version,
indexes,
)?,
indexes_to_blocks_before_next_difficulty_adjustment: ComputedBlockLast::forced_import(
blocks_before_next_difficulty_adjustment: ComputedBlockLast::forced_import(
db,
"blocks_before_next_difficulty_adjustment",
version + v2,
indexes,
)?,
indexes_to_days_before_next_difficulty_adjustment: ComputedBlockLast::forced_import(
days_before_next_difficulty_adjustment: ComputedBlockLast::forced_import(
db,
"days_before_next_difficulty_adjustment",
version + v2,
@@ -6,7 +6,7 @@ use crate::internal::{ComputedBlockLast, ComputedDateLast};
/// Difficulty epoch metrics and countdown
#[derive(Clone, Traversable)]
pub struct Vecs {
pub indexes_to_difficultyepoch: ComputedDateLast<DifficultyEpoch>,
pub indexes_to_blocks_before_next_difficulty_adjustment: ComputedBlockLast<StoredU32>,
pub indexes_to_days_before_next_difficulty_adjustment: ComputedBlockLast<StoredF32>,
pub difficultyepoch: ComputedDateLast<DifficultyEpoch>,
pub blocks_before_next_difficulty_adjustment: ComputedBlockLast<StoredU32>,
pub days_before_next_difficulty_adjustment: ComputedBlockLast<StoredF32>,
}