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

@@ -27,7 +27,7 @@ impl Vecs {
self.size
.compute(indexer, &self.lookback, starting_indexes, exit)?;
self.weight
.compute(indexer, &self.lookback, starting_indexes, exit)?;
.compute(indexer, starting_indexes, exit)?;
self.difficulty
.compute(indexer, indexes, starting_indexes, exit)?;
self.halving.compute(indexes, starting_indexes, exit)?;

View File

@@ -24,7 +24,7 @@ impl Vecs {
total: ComputedPerBlockCumulativeWithSums::forced_import(
db,
"block_count",
version,
version + Version::ONE,
indexes,
cached_starts,
)?,

View File

@@ -29,7 +29,7 @@ impl Vecs {
let count = CountVecs::forced_import(&db, version, indexes, cached_starts)?;
let interval = IntervalVecs::forced_import(&db, version, indexes, cached_starts)?;
let size = SizeVecs::forced_import(&db, version, indexes, cached_starts)?;
let weight = WeightVecs::forced_import(&db, version, indexes, cached_starts)?;
let weight = WeightVecs::forced_import(&db, version, indexes, cached_starts, &size)?;
let time = TimeVecs::forced_import(&db, version, indexes)?;
let difficulty = DifficultyVecs::forced_import(&db, version, indexer, indexes)?;
let halving = HalvingVecs::forced_import(&db, version, indexes)?;

View File

@@ -4,25 +4,14 @@ use brk_types::{BasisPoints16, Indexes};
use vecdb::Exit;
use super::Vecs;
use crate::blocks;
impl Vecs {
pub(crate) fn compute(
&mut self,
indexer: &Indexer,
lookback: &blocks::LookbackVecs,
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
let window_starts = lookback.window_starts();
self.weight.compute(
starting_indexes.height,
&window_starts,
&indexer.vecs.blocks.weight,
exit,
)?;
self.fullness
.compute(starting_indexes.height, exit, |vec| {
vec.compute_transform(

View File

@@ -4,8 +4,9 @@ use vecdb::Database;
use super::Vecs;
use crate::{
blocks::SizeVecs,
indexes,
internal::{CachedWindowStarts, ResolutionsFull, PercentPerBlockRollingAverage},
internal::{CachedWindowStarts, LazyResolutionsFull, PercentPerBlockRollingAverage, VBytesToWeight},
};
impl Vecs {
@@ -14,9 +15,15 @@ impl Vecs {
version: Version,
indexes: &indexes::Vecs,
cached_starts: &CachedWindowStarts,
size: &SizeVecs,
) -> Result<Self> {
let weight =
ResolutionsFull::forced_import(db, "block_weight", version, indexes, cached_starts)?;
let weight = LazyResolutionsFull::from_computed_per_block_full::<VBytesToWeight>(
"block_weight",
version,
&size.vbytes,
cached_starts,
indexes,
);
let fullness = PercentPerBlockRollingAverage::forced_import(
db,

View File

@@ -1,11 +1,11 @@
use brk_traversable::Traversable;
use brk_types::{BasisPoints16, Weight};
use brk_types::{BasisPoints16, StoredU64, Weight};
use vecdb::{Rw, StorageMode};
use crate::internal::{ResolutionsFull, PercentPerBlockRollingAverage};
use crate::internal::{LazyResolutionsFull, PercentPerBlockRollingAverage};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub weight: ResolutionsFull<Weight, M>,
pub weight: LazyResolutionsFull<Weight, StoredU64>,
pub fullness: PercentPerBlockRollingAverage<BasisPoints16, M>,
}