global: snapshot

This commit is contained in:
nym21
2026-01-13 22:32:29 +01:00
parent 0c442b4a71
commit e77993fb76
61 changed files with 5047 additions and 5404 deletions

View File

@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_indexer::Indexer;
use brk_types::{Date, Height, Version};
use vecdb::{Database, EagerVec, ImportableVec, IterableCloneableVec, LazyVecFrom1, VecIndex};
use vecdb::{Database, EagerVec, ImportableVec, IterableCloneableVec, LazyVecFrom1};
use super::Vecs;
use crate::{indexes, internal::ComputedHeightDerivedFirst};
@@ -13,25 +13,17 @@ impl Vecs {
indexer: &Indexer,
indexes: &indexes::Vecs,
) -> Result<Self> {
let height_to_timestamp_monotonic =
let timestamp_monotonic =
EagerVec::forced_import(db, "timestamp_monotonic", version)?;
Ok(Self {
date: LazyVecFrom1::init(
"date",
version,
indexer.vecs.blocks.timestamp.boxed_clone(),
|height: Height, timestamp_iter| {
timestamp_iter.get_at(height.to_usize()).map(Date::from)
},
),
date_monotonic: LazyVecFrom1::init(
"date_monotonic",
version,
height_to_timestamp_monotonic.boxed_clone(),
timestamp_monotonic.boxed_clone(),
|height: Height, timestamp_iter| timestamp_iter.get(height).map(Date::from),
),
timestamp_monotonic: height_to_timestamp_monotonic,
timestamp_monotonic,
timestamp: ComputedHeightDerivedFirst::forced_import(
db,
"timestamp",

View File

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