mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-18 14:38:10 -07:00
global: big snapshot
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{BasisPoints16, Height, Indexes, PoolSlug, StoredU32};
|
||||
use brk_types::{BasisPoints16, Height, Indexes, PoolSlug, StoredU32, StoredU64};
|
||||
use vecdb::{
|
||||
Database, Exit, ReadableVec, Rw, StorageMode, Version,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
blocks, indexes,
|
||||
internal::{ComputedPerBlockCumulative, PercentPerBlock, RatioU32Bp16},
|
||||
internal::{
|
||||
CachedWindowStarts, ComputedPerBlockCumulativeWithSums, PercentPerBlock, RatioU64Bp16,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Traversable)]
|
||||
@@ -15,7 +17,7 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
#[traversable(skip)]
|
||||
slug: PoolSlug,
|
||||
|
||||
pub blocks_mined: ComputedPerBlockCumulative<StoredU32, M>,
|
||||
pub blocks_mined: ComputedPerBlockCumulativeWithSums<StoredU32, StoredU64, M>,
|
||||
pub dominance: PercentPerBlock<BasisPoints16, M>,
|
||||
}
|
||||
|
||||
@@ -25,14 +27,16 @@ impl Vecs {
|
||||
slug: PoolSlug,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
cached_starts: &CachedWindowStarts,
|
||||
) -> Result<Self> {
|
||||
let suffix = |s: &str| format!("{}_{s}", slug);
|
||||
|
||||
let blocks_mined = ComputedPerBlockCumulative::forced_import(
|
||||
let blocks_mined = ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
&suffix("blocks_mined"),
|
||||
version,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?;
|
||||
|
||||
let dominance =
|
||||
@@ -73,7 +77,7 @@ impl Vecs {
|
||||
})?;
|
||||
|
||||
self.dominance
|
||||
.compute_binary::<StoredU32, StoredU32, RatioU32Bp16>(
|
||||
.compute_binary::<StoredU64, StoredU64, RatioU64Bp16>(
|
||||
starting_indexes.height,
|
||||
&self.blocks_mined.cumulative.height,
|
||||
&blocks.count.total.cumulative.height,
|
||||
|
||||
Reference in New Issue
Block a user