global: snapshot

This commit is contained in:
nym21
2026-03-13 13:51:47 +01:00
parent 2b31c7f6b7
commit b2a1251774
27 changed files with 2131 additions and 1317 deletions

View File

@@ -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)?;

View File

@@ -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 })
}
}

View File

@@ -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>,
}