computer: snapshot

This commit is contained in:
nym21
2026-03-09 14:27:35 +01:00
parent e4bd11317a
commit cba3b7dc38
178 changed files with 1089 additions and 1089 deletions

View File

@@ -4,7 +4,7 @@ use brk_types::{StoredBool, TxIndex, Version};
use vecdb::{Database, LazyVecFrom2, ReadableCloneableVec};
use super::Vecs;
use crate::{indexes, internal::ComputedFromHeightFull};
use crate::{indexes, internal::ComputedPerBlockFull};
impl Vecs {
pub(crate) fn forced_import(
@@ -26,7 +26,7 @@ impl Vecs {
);
Ok(Self {
tx_count: ComputedFromHeightFull::forced_import(db, "tx_count", version, indexes)?,
tx_count: ComputedPerBlockFull::forced_import(db, "tx_count", version, indexes)?,
is_coinbase: txindex_to_is_coinbase,
})
}

View File

@@ -2,10 +2,10 @@ use brk_traversable::Traversable;
use brk_types::{Height, StoredBool, StoredU64, TxIndex};
use vecdb::{LazyVecFrom2, Rw, StorageMode};
use crate::internal::ComputedFromHeightFull;
use crate::internal::ComputedPerBlockFull;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub tx_count: ComputedFromHeightFull<StoredU64, M>,
pub tx_count: ComputedPerBlockFull<StoredU64, M>,
pub is_coinbase: LazyVecFrom2<TxIndex, StoredBool, TxIndex, Height, Height, TxIndex>,
}

View File

@@ -3,7 +3,7 @@ use brk_types::Version;
use vecdb::{Database, EagerVec, ImportableVec};
use super::Vecs;
use crate::internal::ComputedFromTxDistribution;
use crate::internal::ComputedPerTxDistribution;
/// Bump this when fee/feerate aggregation logic changes (e.g., skip coinbase).
const VERSION: Version = Version::new(2);
@@ -14,8 +14,8 @@ impl Vecs {
Ok(Self {
input_value: EagerVec::forced_import(db, "input_value", version)?,
output_value: EagerVec::forced_import(db, "output_value", version)?,
fee: ComputedFromTxDistribution::forced_import(db, "fee", v)?,
fee_rate: ComputedFromTxDistribution::forced_import(db, "fee_rate", v)?,
fee: ComputedPerTxDistribution::forced_import(db, "fee", v)?,
fee_rate: ComputedPerTxDistribution::forced_import(db, "fee_rate", v)?,
})
}
}

View File

@@ -2,12 +2,12 @@ use brk_traversable::Traversable;
use brk_types::{FeeRate, Sats, TxIndex};
use vecdb::{EagerVec, PcoVec, Rw, StorageMode};
use crate::internal::ComputedFromTxDistribution;
use crate::internal::ComputedPerTxDistribution;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub input_value: M::Stored<EagerVec<PcoVec<TxIndex, Sats>>>,
pub output_value: M::Stored<EagerVec<PcoVec<TxIndex, Sats>>>,
pub fee: ComputedFromTxDistribution<Sats, M>,
pub fee_rate: ComputedFromTxDistribution<FeeRate, M>,
pub fee: ComputedPerTxDistribution<Sats, M>,
pub fee_rate: ComputedPerTxDistribution<FeeRate, M>,
}

View File

@@ -4,7 +4,7 @@ use brk_types::{TxIndex, VSize, Version, Weight};
use vecdb::{Database, LazyVecFrom2, ReadableCloneableVec};
use super::Vecs;
use crate::internal::LazyFromTxDistribution;
use crate::internal::LazyPerTxDistribution;
impl Vecs {
pub(crate) fn forced_import(
@@ -31,13 +31,13 @@ impl Vecs {
);
Ok(Self {
vsize: LazyFromTxDistribution::forced_import(
vsize: LazyPerTxDistribution::forced_import(
db,
"tx_vsize",
version,
txindex_to_vsize,
)?,
weight: LazyFromTxDistribution::forced_import(
weight: LazyPerTxDistribution::forced_import(
db,
"tx_weight",
version,

View File

@@ -2,10 +2,10 @@ use brk_traversable::Traversable;
use brk_types::{StoredU32, VSize, Weight};
use vecdb::{Rw, StorageMode};
use crate::internal::LazyFromTxDistribution;
use crate::internal::LazyPerTxDistribution;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub vsize: LazyFromTxDistribution<VSize, StoredU32, StoredU32, M>,
pub weight: LazyFromTxDistribution<Weight, StoredU32, StoredU32, M>,
pub vsize: LazyPerTxDistribution<VSize, StoredU32, StoredU32, M>,
pub weight: LazyPerTxDistribution<Weight, StoredU32, StoredU32, M>,
}

View File

@@ -4,7 +4,7 @@ use brk_types::{Indexes, StoredU64, TxVersion};
use vecdb::{Exit, ReadableVec, VecIndex};
use super::Vecs;
use crate::{blocks, internal::ComputedFromHeightCumulativeSum};
use crate::{blocks, internal::ComputedPerBlockCumulativeSum};
impl Vecs {
pub(crate) fn compute(
@@ -16,7 +16,7 @@ impl Vecs {
) -> Result<()> {
let window_starts = lookback.window_starts();
let tx_vany = |tx_vany: &mut ComputedFromHeightCumulativeSum<StoredU64>,
let tx_vany = |tx_vany: &mut ComputedPerBlockCumulativeSum<StoredU64>,
txversion: TxVersion| {
let txversion_vec = &indexer.vecs.transactions.txversion;
// Cursor avoids per-transaction PcoVec page decompression.

View File

@@ -3,7 +3,7 @@ use brk_types::Version;
use vecdb::Database;
use super::Vecs;
use crate::{indexes, internal::ComputedFromHeightCumulativeSum};
use crate::{indexes, internal::ComputedPerBlockCumulativeSum};
impl Vecs {
pub(crate) fn forced_import(
@@ -12,9 +12,9 @@ impl Vecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
v1: ComputedFromHeightCumulativeSum::forced_import(db, "tx_v1", version, indexes)?,
v2: ComputedFromHeightCumulativeSum::forced_import(db, "tx_v2", version, indexes)?,
v3: ComputedFromHeightCumulativeSum::forced_import(db, "tx_v3", version, indexes)?,
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)?,
})
}
}

View File

@@ -2,11 +2,11 @@ use brk_traversable::Traversable;
use brk_types::StoredU64;
use vecdb::{Rw, StorageMode};
use crate::internal::ComputedFromHeightCumulativeSum;
use crate::internal::ComputedPerBlockCumulativeSum;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub v1: ComputedFromHeightCumulativeSum<StoredU64, M>,
pub v2: ComputedFromHeightCumulativeSum<StoredU64, M>,
pub v3: ComputedFromHeightCumulativeSum<StoredU64, M>,
pub v1: ComputedPerBlockCumulativeSum<StoredU64, M>,
pub v2: ComputedPerBlockCumulativeSum<StoredU64, M>,
pub v3: ComputedPerBlockCumulativeSum<StoredU64, M>,
}

View File

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

View File

@@ -2,14 +2,14 @@ use brk_traversable::Traversable;
use brk_types::StoredF32;
use vecdb::{Rw, StorageMode};
use crate::internal::{AmountFromHeight, AmountFromHeightRolling, ComputedFromHeight};
use crate::internal::{AmountPerBlock, AmountPerBlockRolling, ComputedPerBlock};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
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>,
pub sent_sum: AmountPerBlockRolling<M>,
pub received_sum: AmountPerBlockRolling<M>,
pub annualized_volume: AmountPerBlock<M>,
pub tx_per_sec: ComputedPerBlock<StoredF32, M>,
pub outputs_per_sec: ComputedPerBlock<StoredF32, M>,
pub inputs_per_sec: ComputedPerBlock<StoredF32, M>,
}