mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-03 15:23:41 -07:00
global: big snapshot
This commit is contained in:
@@ -5,13 +5,10 @@ use vecdb::Exit;
|
||||
|
||||
use super::Vecs;
|
||||
|
||||
use crate::blocks::lookback;
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
lookback: &lookback::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
@@ -22,20 +19,7 @@ impl Vecs {
|
||||
|h| (h, StoredU32::from(1_u32)),
|
||||
exit,
|
||||
)?;
|
||||
self.total.cumulative.height.compute_cumulative(
|
||||
starting_indexes.height,
|
||||
&self.total.raw.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// Rolling window block counts
|
||||
let ws = lookback.window_starts();
|
||||
self.total.sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&ws,
|
||||
&self.total.raw.height,
|
||||
exit,
|
||||
)?;
|
||||
self.total.compute_rest(starting_indexes.height, exit)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{BlockCountTarget, ComputedPerBlockCumulativeSum, ConstantVecs},
|
||||
internal::{BlockCountTarget, CachedWindowStarts, ComputedPerBlockCumulativeWithSums, ConstantVecs},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -13,6 +13,7 @@ impl Vecs {
|
||||
db: &Database,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
cached_starts: &CachedWindowStarts,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
target: ConstantVecs::new::<BlockCountTarget>(
|
||||
@@ -20,11 +21,12 @@ impl Vecs {
|
||||
version,
|
||||
indexes,
|
||||
),
|
||||
total: ComputedPerBlockCumulativeSum::forced_import(
|
||||
total: ComputedPerBlockCumulativeWithSums::forced_import(
|
||||
db,
|
||||
"block_count",
|
||||
version,
|
||||
indexes,
|
||||
cached_starts,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{StoredU32, StoredU64};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{ComputedPerBlockCumulativeSum, ConstantVecs};
|
||||
use crate::internal::{ComputedPerBlockCumulativeWithSums, ConstantVecs};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub target: ConstantVecs<StoredU64>,
|
||||
pub total: ComputedPerBlockCumulativeSum<StoredU32, M>,
|
||||
pub total: ComputedPerBlockCumulativeWithSums<StoredU32, StoredU64, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user