mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 23:29:58 -07:00
global: snapshot
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user