mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-28 08:39:59 -07:00
global: snapshot
This commit is contained in:
@@ -14,9 +14,6 @@ impl Vecs {
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.weight
|
||||
.derive_from(indexer, indexes, starting_indexes, exit)?;
|
||||
|
||||
self.vsize
|
||||
.derive_from(indexer, indexes, starting_indexes, exit)?;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use brk_types::{TxIndex, VSize, Version, Weight};
|
||||
use vecdb::{Database, LazyVecFrom2, ReadableCloneableVec};
|
||||
|
||||
use super::Vecs;
|
||||
use crate::internal::LazyPerTxDistribution;
|
||||
use crate::internal::{LazyPerTxDistribution, LazyPerTxDistributionDerived, VSizeToWeight};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(
|
||||
@@ -12,14 +12,6 @@ impl Vecs {
|
||||
version: Version,
|
||||
indexer: &Indexer,
|
||||
) -> Result<Self> {
|
||||
let txindex_to_weight = LazyVecFrom2::init(
|
||||
"tx_weight",
|
||||
version,
|
||||
indexer.vecs.transactions.base_size.read_only_boxed_clone(),
|
||||
indexer.vecs.transactions.total_size.read_only_boxed_clone(),
|
||||
|_index: TxIndex, base_size, total_size| Weight::from_sizes(*base_size, *total_size),
|
||||
);
|
||||
|
||||
let txindex_to_vsize = LazyVecFrom2::init(
|
||||
"tx_vsize",
|
||||
version,
|
||||
@@ -30,19 +22,24 @@ impl Vecs {
|
||||
},
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
vsize: LazyPerTxDistribution::forced_import(
|
||||
db,
|
||||
"tx_vsize",
|
||||
version,
|
||||
txindex_to_vsize,
|
||||
)?,
|
||||
weight: LazyPerTxDistribution::forced_import(
|
||||
db,
|
||||
"tx_weight",
|
||||
version,
|
||||
txindex_to_weight,
|
||||
)?,
|
||||
})
|
||||
let vsize =
|
||||
LazyPerTxDistribution::forced_import(db, "tx_vsize", version, txindex_to_vsize)?;
|
||||
|
||||
let txindex_to_weight = LazyVecFrom2::init(
|
||||
"tx_weight",
|
||||
version,
|
||||
indexer.vecs.transactions.base_size.read_only_boxed_clone(),
|
||||
indexer.vecs.transactions.total_size.read_only_boxed_clone(),
|
||||
|_index: TxIndex, base_size, total_size| Weight::from_sizes(*base_size, *total_size),
|
||||
);
|
||||
|
||||
let weight = LazyPerTxDistributionDerived::new::<VSizeToWeight>(
|
||||
"tx_weight",
|
||||
version,
|
||||
txindex_to_weight,
|
||||
&vsize.distribution,
|
||||
);
|
||||
|
||||
Ok(Self { vsize, weight })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{StoredU32, VSize, Weight};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::LazyPerTxDistribution;
|
||||
use crate::internal::{LazyPerTxDistribution, LazyPerTxDistributionDerived};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub vsize: LazyPerTxDistribution<VSize, StoredU32, StoredU32, M>,
|
||||
pub weight: LazyPerTxDistribution<Weight, StoredU32, StoredU32, M>,
|
||||
pub weight: LazyPerTxDistributionDerived<Weight, StoredU32, StoredU32, VSize>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user