computer: snapshot

This commit is contained in:
nym21
2026-02-26 23:01:51 +01:00
parent cccaf6b206
commit 78fc5ffcf7
69 changed files with 1578 additions and 2205 deletions
@@ -18,26 +18,26 @@ impl Vecs {
starting_indexes: &ComputeIndexes,
exit: &Exit,
) -> Result<()> {
self.total_count.compute_with_skip(
starting_indexes.height,
&indexes.txindex.output_count,
&indexer.vecs.transactions.first_txindex,
&indexes.height.txindex_count,
exit,
0,
)?;
let window_starts = blocks.count.window_starts();
self.total_count_rolling.compute(
self.total_count.compute(
starting_indexes.height,
&window_starts,
self.total_count.sum_cumulative.sum.inner(),
exit,
|full| {
full.compute_with_skip(
starting_indexes.height,
&indexes.txindex.output_count,
&indexer.vecs.transactions.first_txindex,
&indexes.height.txindex_count,
exit,
0,
)
},
)?;
self.utxo_count.height.compute_transform3(
starting_indexes.height,
&*self.total_count.sum_cumulative.cumulative,
&*self.total_count.height.sum_cumulative.cumulative,
&*inputs_count.height.sum_cumulative.cumulative,
&scripts_count.opreturn.cumulative.height,
|(h, output_count, input_count, opreturn_count, ..)| {
@@ -5,14 +5,13 @@ use vecdb::Database;
use super::Vecs;
use crate::{
indexes,
internal::{ComputedFromHeightLast, Full, RollingFull},
internal::{ComputedFromHeightFull, ComputedFromHeightLast},
};
impl Vecs {
pub(crate) fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
Ok(Self {
total_count: Full::forced_import(db, "output_count", version)?,
total_count_rolling: RollingFull::forced_import(db, "output_count", version, indexes)?,
total_count: ComputedFromHeightFull::forced_import(db, "output_count", version, indexes)?,
utxo_count: ComputedFromHeightLast::forced_import(db, "exact_utxo_count", version, indexes)?,
})
}
@@ -1,12 +1,11 @@
use brk_traversable::Traversable;
use brk_types::{Height, StoredU64};
use brk_types::StoredU64;
use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedFromHeightLast, Full, RollingFull};
use crate::internal::{ComputedFromHeightFull, ComputedFromHeightLast};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub total_count: Full<Height, StoredU64, M>,
pub total_count_rolling: RollingFull<StoredU64, M>,
pub total_count: ComputedFromHeightFull<StoredU64, M>,
pub utxo_count: ComputedFromHeightLast<StoredU64, M>,
}