mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-28 08:39:59 -07:00
global: snapshot
This commit is contained in:
@@ -4,7 +4,7 @@ use brk_types::{StoredBool, TxIndex, Version};
|
||||
use vecdb::{Database, LazyVecFrom2, ReadableCloneableVec};
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ComputedFromHeightCumulativeFull};
|
||||
use crate::{indexes, internal::ComputedFromHeightFull};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(
|
||||
@@ -24,7 +24,7 @@ impl Vecs {
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
tx_count: ComputedFromHeightCumulativeFull::forced_import(
|
||||
tx_count: ComputedFromHeightFull::forced_import(
|
||||
db, "tx_count", version, indexes,
|
||||
)?,
|
||||
is_coinbase: txindex_to_is_coinbase,
|
||||
|
||||
@@ -2,10 +2,10 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{Height, StoredBool, StoredU64, TxIndex};
|
||||
use vecdb::{LazyVecFrom2, Rw, StorageMode};
|
||||
|
||||
use crate::internal::ComputedFromHeightCumulativeFull;
|
||||
use crate::internal::ComputedFromHeightFull;
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub tx_count: ComputedFromHeightCumulativeFull<StoredU64, M>,
|
||||
pub tx_count: ComputedFromHeightFull<StoredU64, M>,
|
||||
pub is_coinbase: LazyVecFrom2<TxIndex, StoredBool, TxIndex, Height, Height, TxIndex>,
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
||||
use super::Vecs;
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{ComputedFromHeightLast, ValueFromHeightLast, ValueFromHeightLastRolling},
|
||||
internal::{ComputedFromHeight, ValueFromHeight, ValueFromHeightRolling},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
@@ -16,31 +16,31 @@ impl Vecs {
|
||||
) -> Result<Self> {
|
||||
let v2 = Version::TWO;
|
||||
Ok(Self {
|
||||
sent_sum: ValueFromHeightLastRolling::forced_import(
|
||||
sent_sum: ValueFromHeightRolling::forced_import(
|
||||
db, "sent_sum", version, indexes,
|
||||
)?,
|
||||
received_sum: ValueFromHeightLastRolling::forced_import(
|
||||
received_sum: ValueFromHeightRolling::forced_import(
|
||||
db, "received_sum", version, indexes,
|
||||
)?,
|
||||
annualized_volume: ValueFromHeightLast::forced_import(
|
||||
annualized_volume: ValueFromHeight::forced_import(
|
||||
db,
|
||||
"annualized_volume",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
tx_per_sec: ComputedFromHeightLast::forced_import(
|
||||
tx_per_sec: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"tx_per_sec",
|
||||
version + v2,
|
||||
indexes,
|
||||
)?,
|
||||
outputs_per_sec: ComputedFromHeightLast::forced_import(
|
||||
outputs_per_sec: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"outputs_per_sec",
|
||||
version + v2,
|
||||
indexes,
|
||||
)?,
|
||||
inputs_per_sec: ComputedFromHeightLast::forced_import(
|
||||
inputs_per_sec: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"inputs_per_sec",
|
||||
version + v2,
|
||||
|
||||
@@ -3,16 +3,16 @@ use brk_types::StoredF32;
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{
|
||||
ComputedFromHeightLast, ValueFromHeightLast, ValueFromHeightLastRolling,
|
||||
ComputedFromHeight, ValueFromHeight, ValueFromHeightRolling,
|
||||
};
|
||||
|
||||
/// Volume metrics
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub sent_sum: ValueFromHeightLastRolling<M>,
|
||||
pub received_sum: ValueFromHeightLastRolling<M>,
|
||||
pub annualized_volume: ValueFromHeightLast<M>,
|
||||
pub tx_per_sec: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub outputs_per_sec: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub inputs_per_sec: ComputedFromHeightLast<StoredF32, M>,
|
||||
pub sent_sum: ValueFromHeightRolling<M>,
|
||||
pub received_sum: ValueFromHeightRolling<M>,
|
||||
pub annualized_volume: ValueFromHeight<M>,
|
||||
pub tx_per_sec: ComputedFromHeight<StoredF32, M>,
|
||||
pub outputs_per_sec: ComputedFromHeight<StoredF32, M>,
|
||||
pub inputs_per_sec: ComputedFromHeight<StoredF32, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user