global: snapshot

This commit is contained in:
nym21
2026-01-13 01:18:27 +01:00
parent 5ffb66c0dc
commit 670aa95494
35 changed files with 10804 additions and 6166 deletions

View File

@@ -77,11 +77,11 @@ impl Vecs {
where
F: FnOnce(&mut Self) -> &mut EagerVec<PcoVec<Height, Height>>,
{
let mut iter = time.timestamp_fixed.into_iter();
let mut iter = time.timestamp_monotonic.into_iter();
let mut prev = Height::ZERO;
Ok(get_field(self).compute_transform(
starting_indexes.height,
&time.timestamp_fixed,
&time.timestamp_monotonic,
|(h, t, ..)| {
while t.difference_in_days_between(iter.get_unwrap(prev)) >= days {
prev.increment();

View File

@@ -15,24 +15,24 @@ impl Vecs {
starting_height: brk_types::Height,
exit: &Exit,
) -> Result<()> {
let mut prev_timestamp_fixed = None;
self.timestamp_fixed.compute_transform(
let mut prev_timestamp_monotonic = None;
self.timestamp_monotonic.compute_transform(
starting_height,
&indexer.vecs.blocks.timestamp,
|(h, timestamp, height_to_timestamp_fixed_iter)| {
if prev_timestamp_fixed.is_none()
|(h, timestamp, height_to_timestamp_monotonic_iter)| {
if prev_timestamp_monotonic.is_none()
&& let Some(prev_h) = h.decremented()
{
prev_timestamp_fixed.replace(
height_to_timestamp_fixed_iter
prev_timestamp_monotonic.replace(
height_to_timestamp_monotonic_iter
.into_iter()
.get_unwrap(prev_h),
);
}
let timestamp_fixed =
prev_timestamp_fixed.map_or(timestamp, |prev_d| prev_d.max(timestamp));
prev_timestamp_fixed.replace(timestamp_fixed);
(h, timestamp_fixed)
let timestamp_monotonic =
prev_timestamp_monotonic.map_or(timestamp, |prev_d| prev_d.max(timestamp));
prev_timestamp_monotonic.replace(timestamp_monotonic);
(h, timestamp_monotonic)
},
exit,
)?;

View File

@@ -13,7 +13,8 @@ impl Vecs {
indexer: &Indexer,
indexes: &indexes::Vecs,
) -> Result<Self> {
let height_to_timestamp_fixed = EagerVec::forced_import(db, "timestamp_fixed", version)?;
let height_to_timestamp_monotonic =
EagerVec::forced_import(db, "timestamp_monotonic", version)?;
Ok(Self {
date: LazyVecFrom1::init(
@@ -24,13 +25,13 @@ impl Vecs {
timestamp_iter.get_at(height.to_usize()).map(Date::from)
},
),
date_fixed: LazyVecFrom1::init(
"date_fixed",
date_monotonic: LazyVecFrom1::init(
"date_monotonic",
version,
height_to_timestamp_fixed.boxed_clone(),
height_to_timestamp_monotonic.boxed_clone(),
|height: Height, timestamp_iter| timestamp_iter.get(height).map(Date::from),
),
timestamp_fixed: height_to_timestamp_fixed,
timestamp_monotonic: height_to_timestamp_monotonic,
timestamp: ComputedHeightDerivedFirst::forced_import(
db,
"timestamp",

View File

@@ -8,7 +8,7 @@ use crate::internal::ComputedHeightDerivedFirst;
#[derive(Clone, Traversable)]
pub struct Vecs {
pub date: LazyVecFrom1<Height, Date, Height, Timestamp>,
pub date_fixed: LazyVecFrom1<Height, Date, Height, Timestamp>,
pub timestamp_fixed: EagerVec<PcoVec<Height, Timestamp>>,
pub date_monotonic: LazyVecFrom1<Height, Date, Height, Timestamp>,
pub timestamp_monotonic: EagerVec<PcoVec<Height, Timestamp>>,
pub timestamp: ComputedHeightDerivedFirst<Timestamp>,
}

View File

@@ -6,7 +6,7 @@ use vecdb::{Database, IterableCloneableVec};
use super::Vecs;
use crate::{
indexes,
internal::{ComputedHeightDerivedFull, LazyFromHeightFull, WeightToFullness},
internal::{ComputedHeightDerivedFull, LazyFromHeightTransformDistribution, WeightToFullness},
};
impl Vecs {
@@ -24,7 +24,7 @@ impl Vecs {
indexes,
)?;
let fullness = LazyFromHeightFull::from_derived::<WeightToFullness>(
let fullness = LazyFromHeightTransformDistribution::from_derived::<WeightToFullness>(
"block_fullness",
version,
indexer.vecs.blocks.weight.boxed_clone(),

View File

@@ -1,10 +1,10 @@
use brk_traversable::Traversable;
use brk_types::{StoredF32, Weight};
use crate::internal::{ComputedHeightDerivedFull, LazyFromHeightFull};
use crate::internal::{ComputedHeightDerivedFull, LazyFromHeightTransformDistribution};
#[derive(Clone, Traversable)]
pub struct Vecs {
pub weight: ComputedHeightDerivedFull<Weight>,
pub fullness: LazyFromHeightFull<StoredF32, Weight>,
pub fullness: LazyFromHeightTransformDistribution<StoredF32, Weight>,
}