mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-05 08:08:15 -07:00
global: snapshot
This commit is contained in:
@@ -6,7 +6,9 @@ use vecdb::{Database, ReadableCloneableVec};
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{ComputedPerBlock, Resolutions, PercentPerBlock},
|
||||
internal::{
|
||||
BlocksToDaysF32, DifficultyToHashF64, LazyPerBlock, PerBlock, PercentPerBlock, Resolutions,
|
||||
},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -18,33 +20,39 @@ impl Vecs {
|
||||
) -> Result<Self> {
|
||||
let v2 = Version::TWO;
|
||||
|
||||
let as_hash = LazyPerBlock::from_height_source::<DifficultyToHashF64>(
|
||||
"difficulty_as_hash",
|
||||
version,
|
||||
indexer.vecs.blocks.difficulty.read_only_boxed_clone(),
|
||||
indexes,
|
||||
);
|
||||
|
||||
let blocks_before_next = PerBlock::forced_import(
|
||||
db,
|
||||
"blocks_before_next_difficulty_adjustment",
|
||||
version + v2,
|
||||
indexes,
|
||||
)?;
|
||||
|
||||
let days_before_next = LazyPerBlock::from_computed::<BlocksToDaysF32>(
|
||||
"days_before_next_difficulty_adjustment",
|
||||
version + v2,
|
||||
blocks_before_next.height.read_only_boxed_clone(),
|
||||
&blocks_before_next,
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
raw: Resolutions::forced_import(
|
||||
base: Resolutions::forced_import(
|
||||
"difficulty",
|
||||
indexer.vecs.blocks.difficulty.read_only_boxed_clone(),
|
||||
version,
|
||||
indexes,
|
||||
),
|
||||
as_hash: ComputedPerBlock::forced_import(db, "difficulty_as_hash", version, indexes)?,
|
||||
adjustment: PercentPerBlock::forced_import(
|
||||
db,
|
||||
"difficulty_adjustment",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
epoch: ComputedPerBlock::forced_import(db, "difficulty_epoch", version, indexes)?,
|
||||
blocks_before_next: ComputedPerBlock::forced_import(
|
||||
db,
|
||||
"blocks_before_next_difficulty_adjustment",
|
||||
version + v2,
|
||||
indexes,
|
||||
)?,
|
||||
days_before_next: ComputedPerBlock::forced_import(
|
||||
db,
|
||||
"days_before_next_difficulty_adjustment",
|
||||
version + v2,
|
||||
indexes,
|
||||
)?,
|
||||
as_hash,
|
||||
adjustment: PercentPerBlock::forced_import(db, "difficulty_adjustment", version, indexes)?,
|
||||
epoch: PerBlock::forced_import(db, "difficulty_epoch", version, indexes)?,
|
||||
blocks_before_next,
|
||||
days_before_next,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user