global: snapshot

This commit is contained in:
nym21
2026-03-01 12:46:07 +01:00
parent e10013fd2c
commit 7bf0220f25
35 changed files with 1450 additions and 2044 deletions
+1 -5
View File
@@ -1,7 +1,7 @@
use brk_traversable::Traversable;
use brk_types::{
Day1, Day3, Year10, DifficultyEpoch, HalvingEpoch, Height, Hour1, Hour12, Hour4,
Minute1, Minute10, Minute30, Minute5, Month1, Month3, Month6, StoredU64, Version, Week1,
Minute10, Minute30, Month1, Month3, Month6, StoredU64, Version, Week1,
Year1,
};
use vecdb::{Database, EagerVec, ImportableVec, PcoVec, Rw, StorageMode};
@@ -11,8 +11,6 @@ use brk_error::Result;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub identity: M::Stored<EagerVec<PcoVec<Height, Height>>>,
pub minute1: M::Stored<EagerVec<PcoVec<Height, Minute1>>>,
pub minute5: M::Stored<EagerVec<PcoVec<Height, Minute5>>>,
pub minute10: M::Stored<EagerVec<PcoVec<Height, Minute10>>>,
pub minute30: M::Stored<EagerVec<PcoVec<Height, Minute30>>>,
pub hour1: M::Stored<EagerVec<PcoVec<Height, Hour1>>>,
@@ -35,8 +33,6 @@ impl Vecs {
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
Ok(Self {
identity: EagerVec::forced_import(db, "height", version)?,
minute1: EagerVec::forced_import(db, "minute1", version)?,
minute5: EagerVec::forced_import(db, "minute5", version)?,
minute10: EagerVec::forced_import(db, "minute10", version)?,
minute30: EagerVec::forced_import(db, "minute30", version)?,
hour1: EagerVec::forced_import(db, "hour1", version)?,
@@ -1,20 +0,0 @@
use brk_traversable::Traversable;
use brk_types::{Height, Minute1, Version};
use vecdb::{Database, EagerVec, ImportableVec, PcoVec, Rw, StorageMode};
use brk_error::Result;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub identity: M::Stored<EagerVec<PcoVec<Minute1, Minute1>>>,
pub first_height: M::Stored<EagerVec<PcoVec<Minute1, Height>>>,
}
impl Vecs {
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
Ok(Self {
identity: EagerVec::forced_import(db, "minute1", version)?,
first_height: EagerVec::forced_import(db, "minute1_first_height", version)?,
})
}
}
@@ -1,20 +0,0 @@
use brk_traversable::Traversable;
use brk_types::{Height, Minute5, Version};
use vecdb::{Database, EagerVec, ImportableVec, PcoVec, Rw, StorageMode};
use brk_error::Result;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub identity: M::Stored<EagerVec<PcoVec<Minute5, Minute5>>>,
pub first_height: M::Stored<EagerVec<PcoVec<Minute5, Height>>>,
}
impl Vecs {
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
Ok(Self {
identity: EagerVec::forced_import(db, "minute5", version)?,
first_height: EagerVec::forced_import(db, "minute5_first_height", version)?,
})
}
}
+1 -61
View File
@@ -7,10 +7,8 @@ mod height;
mod hour1;
mod hour12;
mod hour4;
mod minute1;
mod minute10;
mod minute30;
mod minute5;
mod month1;
mod month3;
mod month6;
@@ -27,7 +25,7 @@ use brk_error::Result;
use brk_indexer::Indexer;
use brk_traversable::Traversable;
use brk_types::{
Date, Day1, Day3, Hour1, Hour4, Hour12, Indexes, Minute1, Minute5, Minute10, Minute30, Month1,
Date, Day1, Day3, Hour1, Hour4, Hour12, Indexes, Minute10, Minute30, Month1,
Month3, Month6, Version, Week1, Year1, Year10,
};
use vecdb::{Database, Exit, PAGE_SIZE, ReadableVec, Rw, StorageMode};
@@ -44,8 +42,6 @@ pub use height::Vecs as HeightVecs;
pub use hour1::Vecs as Hour1Vecs;
pub use hour4::Vecs as Hour4Vecs;
pub use hour12::Vecs as Hour12Vecs;
pub use minute1::Vecs as Minute1Vecs;
pub use minute5::Vecs as Minute5Vecs;
pub use minute10::Vecs as Minute10Vecs;
pub use minute30::Vecs as Minute30Vecs;
pub use month1::Vecs as Month1Vecs;
@@ -68,8 +64,6 @@ pub struct Vecs<M: StorageMode = Rw> {
pub height: HeightVecs<M>,
pub difficultyepoch: DifficultyEpochVecs<M>,
pub halvingepoch: HalvingEpochVecs<M>,
pub minute1: Minute1Vecs<M>,
pub minute5: Minute5Vecs<M>,
pub minute10: Minute10Vecs<M>,
pub minute30: Minute30Vecs<M>,
pub hour1: Hour1Vecs<M>,
@@ -104,8 +98,6 @@ impl Vecs {
height: HeightVecs::forced_import(&db, version)?,
difficultyepoch: DifficultyEpochVecs::forced_import(&db, version)?,
halvingepoch: HalvingEpochVecs::forced_import(&db, version)?,
minute1: Minute1Vecs::forced_import(&db, version)?,
minute5: Minute5Vecs::forced_import(&db, version)?,
minute10: Minute10Vecs::forced_import(&db, version)?,
minute30: Minute30Vecs::forced_import(&db, version)?,
hour1: Hour1Vecs::forced_import(&db, version)?,
@@ -190,22 +182,6 @@ impl Vecs {
// --- Timestamp-based height → period mappings ---
// Minute1
self.height.minute1.compute_transform(
starting_indexes.height,
&blocks_time.timestamp_monotonic,
|(h, ts, _)| (h, Minute1::from_timestamp(ts)),
exit,
)?;
// Minute5
self.height.minute5.compute_transform(
starting_indexes.height,
&blocks_time.timestamp_monotonic,
|(h, ts, _)| (h, Minute5::from_timestamp(ts)),
exit,
)?;
// Minute10
self.height.minute10.compute_transform(
starting_indexes.height,
@@ -376,16 +352,6 @@ impl Vecs {
// --- Starting values from height → period mappings ---
let starting_minute1 = self
.height
.minute1
.collect_one(decremented_starting_height)
.unwrap_or_default();
let starting_minute5 = self
.height
.minute5
.collect_one(decremented_starting_height)
.unwrap_or_default();
let starting_minute10 = self
.height
.minute10
@@ -449,30 +415,6 @@ impl Vecs {
// --- Compute period-level vecs (first_height + identity) ---
// Minute1
self.minute1.first_height.compute_first_per_index(
starting_indexes.height,
&self.height.minute1,
exit,
)?;
self.minute1.identity.compute_from_index(
starting_minute1,
&self.minute1.first_height,
exit,
)?;
// Minute5
self.minute5.first_height.compute_first_per_index(
starting_indexes.height,
&self.height.minute5,
exit,
)?;
self.minute5.identity.compute_from_index(
starting_minute5,
&self.minute5.first_height,
exit,
)?;
// Minute10
self.minute10.first_height.compute_first_per_index(
starting_indexes.height,
@@ -669,8 +611,6 @@ impl Vecs {
Ok(ComputeIndexes::new(
starting_indexes,
starting_minute1,
starting_minute5,
starting_minute10,
starting_minute30,
starting_hour1,