computer: snapshot

This commit is contained in:
nym21
2026-03-09 11:16:50 +01:00
parent 0bff57fb43
commit 3e8cf4a975
92 changed files with 853 additions and 825 deletions

View File

@@ -22,11 +22,11 @@ impl Vecs {
) -> Result<()> {
// Count computes first
self.count
.compute(indexer, &blocks.count, starting_indexes, exit)?;
.compute(indexer, &blocks.lookback, starting_indexes, exit)?;
// Versions depends on count
self.versions
.compute(indexer, &blocks.count, starting_indexes, exit)?;
.compute(indexer, &blocks.lookback, starting_indexes, exit)?;
// Size computes next (uses 6-block rolling window)
self.size

View File

@@ -10,11 +10,11 @@ impl Vecs {
pub(crate) fn compute(
&mut self,
indexer: &Indexer,
count_vecs: &blocks::CountVecs,
lookback: &blocks::LookbackVecs,
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
let window_starts = count_vecs.window_starts();
let window_starts = lookback.window_starts();
self.tx_count
.compute(starting_indexes.height, &window_starts, exit, |height| {
Ok(height.compute_count_from_indexes(

View File

@@ -10,11 +10,11 @@ impl Vecs {
pub(crate) fn compute(
&mut self,
indexer: &Indexer,
count_vecs: &blocks::CountVecs,
lookback: &blocks::LookbackVecs,
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
let window_starts = count_vecs.window_starts();
let window_starts = lookback.window_starts();
let tx_vany = |tx_vany: &mut ComputedFromHeightCumulativeSum<StoredU64>,
txversion: TxVersion| {

View File

@@ -22,7 +22,7 @@ impl Vecs {
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
let window_starts = blocks.count.window_starts();
let window_starts = blocks.lookback.window_starts();
self.sent_sum.compute(
starting_indexes.height,
@@ -60,7 +60,7 @@ impl Vecs {
// Annualized volume: rolling 1y sum of per-block sent volume
self.annualized_volume.sats.height.compute_rolling_sum(
starting_indexes.height,
&blocks.count.height_1y_ago,
&blocks.lookback.height_1y_ago,
&self.sent_sum.sats,
exit,
)?;

View File

@@ -5,7 +5,7 @@ use vecdb::Database;
use super::Vecs;
use crate::{
indexes,
internal::{ComputedFromHeight, ValueFromHeight, ValueFromHeightRolling},
internal::{AmountFromHeight, AmountFromHeightRolling, ComputedFromHeight},
};
impl Vecs {
@@ -16,14 +16,14 @@ impl Vecs {
) -> Result<Self> {
let v2 = Version::TWO;
Ok(Self {
sent_sum: ValueFromHeightRolling::forced_import(db, "sent_sum", version, indexes)?,
received_sum: ValueFromHeightRolling::forced_import(
sent_sum: AmountFromHeightRolling::forced_import(db, "sent_sum", version, indexes)?,
received_sum: AmountFromHeightRolling::forced_import(
db,
"received_sum",
version,
indexes,
)?,
annualized_volume: ValueFromHeight::forced_import(
annualized_volume: AmountFromHeight::forced_import(
db,
"annualized_volume",
version,

View File

@@ -2,13 +2,13 @@ use brk_traversable::Traversable;
use brk_types::StoredF32;
use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedFromHeight, ValueFromHeight, ValueFromHeightRolling};
use crate::internal::{AmountFromHeight, AmountFromHeightRolling, ComputedFromHeight};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub sent_sum: ValueFromHeightRolling<M>,
pub received_sum: ValueFromHeightRolling<M>,
pub annualized_volume: ValueFromHeight<M>,
pub sent_sum: AmountFromHeightRolling<M>,
pub received_sum: AmountFromHeightRolling<M>,
pub annualized_volume: AmountFromHeight<M>,
pub tx_per_sec: ComputedFromHeight<StoredF32, M>,
pub outputs_per_sec: ComputedFromHeight<StoredF32, M>,
pub inputs_per_sec: ComputedFromHeight<StoredF32, M>,