computer: snapshot

This commit is contained in:
nym21
2026-01-09 22:02:34 +01:00
parent 426d7797a3
commit 3a3f6b8593
43 changed files with 3879 additions and 4097 deletions

View File

@@ -13,25 +13,23 @@ impl Vecs {
starting_indexes: &ComputeIndexes,
exit: &Exit,
) -> Result<()> {
let mut height_to_difficultyepoch_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.dateindex.first_height,
|(di, height, ..)| {
(
di,
height_to_difficultyepoch_iter
.get_unwrap(height + (*height_count_iter.get_unwrap(di) - 1)),
)
},
exit,
)?;
Ok(())
})?;
let mut height_to_difficultyepoch_iter = indexes.height.difficultyepoch.into_iter();
self.epoch.compute_all(starting_indexes, exit, |vec| {
let mut height_count_iter = indexes.dateindex.height_count.into_iter();
vec.compute_transform(
starting_indexes.dateindex,
&indexes.dateindex.first_height,
|(di, height, ..)| {
(
di,
height_to_difficultyepoch_iter
.get_unwrap(height + (*height_count_iter.get_unwrap(di) - 1)),
)
},
exit,
)?;
Ok(())
})?;
self.blocks_before_next_difficulty_adjustment.compute_all(
indexes,

View File

@@ -13,12 +13,7 @@ impl Vecs {
let v2 = Version::TWO;
Ok(Self {
difficultyepoch: ComputedDateLast::forced_import(
db,
"difficultyepoch",
version,
indexes,
)?,
epoch: ComputedDateLast::forced_import(db, "difficultyepoch", version, indexes)?,
blocks_before_next_difficulty_adjustment: ComputedBlockLast::forced_import(
db,
"blocks_before_next_difficulty_adjustment",

View File

@@ -6,7 +6,7 @@ use crate::internal::{ComputedBlockLast, ComputedDateLast};
/// Difficulty epoch metrics and countdown
#[derive(Clone, Traversable)]
pub struct Vecs {
pub difficultyepoch: ComputedDateLast<DifficultyEpoch>,
pub epoch: ComputedDateLast<DifficultyEpoch>,
pub blocks_before_next_difficulty_adjustment: ComputedBlockLast<StoredU32>,
pub days_before_next_difficulty_adjustment: ComputedBlockLast<StoredF32>,
}

View File

@@ -14,23 +14,22 @@ impl Vecs {
exit: &Exit,
) -> Result<()> {
let mut height_to_halvingepoch_iter = indexes.height.halvingepoch.into_iter();
self.halvingepoch
.compute_all(starting_indexes, exit, |vec| {
let mut height_count_iter = indexes.dateindex.height_count.into_iter();
vec.compute_transform(
starting_indexes.dateindex,
&indexes.dateindex.first_height,
|(di, height, ..)| {
(
di,
height_to_halvingepoch_iter
.get_unwrap(height + (*height_count_iter.get_unwrap(di) - 1)),
)
},
exit,
)?;
Ok(())
})?;
self.epoch.compute_all(starting_indexes, exit, |vec| {
let mut height_count_iter = indexes.dateindex.height_count.into_iter();
vec.compute_transform(
starting_indexes.dateindex,
&indexes.dateindex.first_height,
|(di, height, ..)| {
(
di,
height_to_halvingepoch_iter
.get_unwrap(height + (*height_count_iter.get_unwrap(di) - 1)),
)
},
exit,
)?;
Ok(())
})?;
self.blocks_before_next_halving
.compute_all(indexes, starting_indexes, exit, |v| {

View File

@@ -13,7 +13,7 @@ impl Vecs {
let v2 = Version::TWO;
Ok(Self {
halvingepoch: ComputedDateLast::forced_import(db, "halvingepoch", version, indexes)?,
epoch: ComputedDateLast::forced_import(db, "halvingepoch", version, indexes)?,
blocks_before_next_halving: ComputedBlockLast::forced_import(
db,
"blocks_before_next_halving",

View File

@@ -6,7 +6,7 @@ use crate::internal::{ComputedBlockLast, ComputedDateLast};
/// Halving epoch metrics and countdown
#[derive(Clone, Traversable)]
pub struct Vecs {
pub halvingepoch: ComputedDateLast<HalvingEpoch>,
pub epoch: ComputedDateLast<HalvingEpoch>,
pub blocks_before_next_halving: ComputedBlockLast<StoredU32>,
pub days_before_next_halving: ComputedBlockLast<StoredF32>,
}