mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-30 22:09:00 -07:00
global: fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Height, Indexes, TimePeriod, Timestamp, Version};
|
||||
use brk_types::{Height, Indexes, Timestamp, Version};
|
||||
use vecdb::{
|
||||
AnyVec, CachedVec, Cursor, Database, EagerVec, Exit, ImportableVec, PcoVec, ReadableVec, Rw,
|
||||
StorageMode, VecIndex,
|
||||
@@ -58,26 +58,6 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub _26y: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 9490d
|
||||
}
|
||||
|
||||
impl<M: StorageMode> Vecs<M> {
|
||||
/// First block height inside `period` looking back from `tip`; `None` for `All`.
|
||||
/// Walks real block timestamps, matching mempool.space's wall-clock
|
||||
/// `time > NOW() - INTERVAL ${period}` cutoff.
|
||||
pub fn start_height(&self, period: TimePeriod, tip: Height) -> Option<Height> {
|
||||
match period {
|
||||
TimePeriod::Day => self._24h.collect_one(tip),
|
||||
TimePeriod::ThreeDays => self._3d.collect_one(tip),
|
||||
TimePeriod::Week => self._1w.collect_one(tip),
|
||||
TimePeriod::Month => self._1m.collect_one(tip),
|
||||
TimePeriod::ThreeMonths => self._3m.collect_one(tip),
|
||||
TimePeriod::SixMonths => self._6m.collect_one(tip),
|
||||
TimePeriod::Year => self._1y.collect_one(tip),
|
||||
TimePeriod::TwoYears => self._2y.collect_one(tip),
|
||||
TimePeriod::ThreeYears => self._3y.collect_one(tip),
|
||||
TimePeriod::All => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
let _1h = ImportableVec::forced_import(db, "height_1h_ago", version)?;
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{fs, path::Path, thread, time::Instant};
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::Version;
|
||||
use brk_types::{Height, Version};
|
||||
use tracing::info;
|
||||
use vecdb::{AnyExportableVec, Exit, Ro, Rw, StorageMode};
|
||||
|
||||
@@ -480,6 +480,14 @@ impl Computer {
|
||||
}
|
||||
}
|
||||
|
||||
impl Computer<Ro> {
|
||||
/// Last height whose computed-side state is durably stamped, derived
|
||||
/// from `distribution.supply_state`'s stamp.
|
||||
pub fn computed_height(&self) -> Height {
|
||||
Height::from(self.distribution.supply_state.stamp())
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_iter_named {
|
||||
($($field:ident),+ $(,)?) => {
|
||||
impl_iter_named!(@mode Ro, $($field),+);
|
||||
|
||||
Reference in New Issue
Block a user