mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-01 06:19:02 -07:00
global: big snapshot
This commit is contained in:
@@ -4,25 +4,22 @@ use brk_types::{Indexes, StoredU64, TxVersion};
|
||||
use vecdb::{Exit, ReadableVec, VecIndex};
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{blocks, internal::ComputedPerBlockCumulativeSum};
|
||||
use crate::internal::ComputedPerBlockCumulativeWithSums;
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
indexer: &Indexer,
|
||||
lookback: &blocks::LookbackVecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let window_starts = lookback.window_starts();
|
||||
|
||||
let tx_vany = |tx_vany: &mut ComputedPerBlockCumulativeSum<StoredU64>,
|
||||
let tx_vany = |tx_vany: &mut ComputedPerBlockCumulativeWithSums<StoredU64, StoredU64>,
|
||||
txversion: TxVersion| {
|
||||
let txversion_vec = &indexer.vecs.transactions.txversion;
|
||||
// Cursor avoids per-transaction PcoVec page decompression.
|
||||
// Txindex values are sequential, so the cursor only advances forward.
|
||||
let mut cursor = txversion_vec.cursor();
|
||||
tx_vany.compute(starting_indexes.height, &window_starts, exit, |vec| {
|
||||
tx_vany.compute(starting_indexes.height, exit, |vec| {
|
||||
vec.compute_filtered_count_from_indexes(
|
||||
starting_indexes.height,
|
||||
&indexer.vecs.transactions.first_txindex,
|
||||
|
||||
@@ -3,18 +3,22 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ComputedPerBlockCumulativeSum};
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{CachedWindowStarts, ComputedPerBlockCumulativeWithSums},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(
|
||||
db: &Database,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
cached_starts: &CachedWindowStarts,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
v1: ComputedPerBlockCumulativeSum::forced_import(db, "tx_v1", version, indexes)?,
|
||||
v2: ComputedPerBlockCumulativeSum::forced_import(db, "tx_v2", version, indexes)?,
|
||||
v3: ComputedPerBlockCumulativeSum::forced_import(db, "tx_v3", version, indexes)?,
|
||||
v1: ComputedPerBlockCumulativeWithSums::forced_import(db, "tx_v1", version, indexes, cached_starts)?,
|
||||
v2: ComputedPerBlockCumulativeWithSums::forced_import(db, "tx_v2", version, indexes, cached_starts)?,
|
||||
v3: ComputedPerBlockCumulativeWithSums::forced_import(db, "tx_v3", version, indexes, cached_starts)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ use brk_traversable::Traversable;
|
||||
use brk_types::StoredU64;
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::ComputedPerBlockCumulativeSum;
|
||||
use crate::internal::ComputedPerBlockCumulativeWithSums;
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub v1: ComputedPerBlockCumulativeSum<StoredU64, M>,
|
||||
pub v2: ComputedPerBlockCumulativeSum<StoredU64, M>,
|
||||
pub v3: ComputedPerBlockCumulativeSum<StoredU64, M>,
|
||||
pub v1: ComputedPerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
|
||||
pub v2: ComputedPerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
|
||||
pub v3: ComputedPerBlockCumulativeWithSums<StoredU64, StoredU64, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user