mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-26 07:39:59 -07:00
computer: snapshot
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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>,
|
||||
}
|
||||
|
||||
@@ -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| {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user