mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-26 18:28:11 -07:00
global: snapshot
This commit is contained in:
@@ -18,11 +18,11 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "dateindex", version)?,
|
||||
date: EagerVec::forced_import(db, "dateindex_date", version)?,
|
||||
first_height: EagerVec::forced_import(db, "dateindex_first_height", version)?,
|
||||
height_count: EagerVec::forced_import(db, "dateindex_height_count", version)?,
|
||||
weekindex: EagerVec::forced_import(db, "dateindex_weekindex", version)?,
|
||||
monthindex: EagerVec::forced_import(db, "dateindex_monthindex", version)?,
|
||||
date: EagerVec::forced_import(db, "date", version + Version::ONE)?,
|
||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
||||
height_count: EagerVec::forced_import(db, "height_count", version)?,
|
||||
weekindex: EagerVec::forced_import(db, "weekindex", version)?,
|
||||
monthindex: EagerVec::forced_import(db, "monthindex", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DecadeIndex, StoredU64, Version, YearIndex};
|
||||
use brk_types::{Date, DecadeIndex, StoredU64, Version, YearIndex};
|
||||
use vecdb::{Database, EagerVec, ImportableVec, PcoVec};
|
||||
|
||||
use brk_error::Result;
|
||||
@@ -7,6 +7,7 @@ use brk_error::Result;
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub identity: EagerVec<PcoVec<DecadeIndex, DecadeIndex>>,
|
||||
pub date: EagerVec<PcoVec<DecadeIndex, Date>>,
|
||||
pub first_yearindex: EagerVec<PcoVec<DecadeIndex, YearIndex>>,
|
||||
pub yearindex_count: EagerVec<PcoVec<DecadeIndex, StoredU64>>,
|
||||
}
|
||||
@@ -15,8 +16,9 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "decadeindex", version)?,
|
||||
first_yearindex: EagerVec::forced_import(db, "decadeindex_first_yearindex", version)?,
|
||||
yearindex_count: EagerVec::forced_import(db, "decadeindex_yearindex_count", version)?,
|
||||
date: EagerVec::forced_import(db, "date", version)?,
|
||||
first_yearindex: EagerVec::forced_import(db, "first_yearindex", version)?,
|
||||
yearindex_count: EagerVec::forced_import(db, "yearindex_count", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "difficultyepoch", version)?,
|
||||
first_height: EagerVec::forced_import(db, "difficultyepoch_first_height", version)?,
|
||||
height_count: EagerVec::forced_import(db, "difficultyepoch_height_count", version)?,
|
||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
||||
height_count: EagerVec::forced_import(db, "height_count", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "halvingepoch", version)?,
|
||||
first_height: EagerVec::forced_import(db, "halvingepoch_first_height", version)?,
|
||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ impl Vecs {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "height", version)?,
|
||||
dateindex: EagerVec::forced_import(db, "height_dateindex", version)?,
|
||||
difficultyepoch: EagerVec::forced_import(db, "height_difficultyepoch", version)?,
|
||||
halvingepoch: EagerVec::forced_import(db, "height_halvingepoch", version)?,
|
||||
txindex_count: EagerVec::forced_import(db, "height_txindex_count", version)?,
|
||||
difficultyepoch: EagerVec::forced_import(db, "difficultyepoch", version)?,
|
||||
halvingepoch: EagerVec::forced_import(db, "halvingepoch", version)?,
|
||||
txindex_count: EagerVec::forced_import(db, "txindex_count", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ use std::path::Path;
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DateIndex, Indexes, MonthIndex, Version, WeekIndex};
|
||||
use vecdb::{Database, Exit, PAGE_SIZE, TypedVecIterator};
|
||||
use brk_types::{Date, DateIndex, Indexes, MonthIndex, Version, WeekIndex};
|
||||
use vecdb::{Database, Exit, IterableVec, PAGE_SIZE, TypedVecIterator};
|
||||
|
||||
use crate::blocks;
|
||||
|
||||
@@ -160,7 +160,7 @@ impl Vecs {
|
||||
|
||||
self.height.dateindex.compute_transform(
|
||||
starting_indexes.height,
|
||||
&blocks_time.date_monotonic,
|
||||
&blocks_time.date,
|
||||
|(h, d, ..)| (h, DateIndex::try_from(d).unwrap()),
|
||||
exit,
|
||||
)?;
|
||||
@@ -250,9 +250,10 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.dateindex.date.compute_from_index(
|
||||
self.dateindex.date.compute_transform(
|
||||
starting_dateindex,
|
||||
&self.dateindex.first_height,
|
||||
&self.dateindex.identity,
|
||||
|(di, ..)| (di, Date::from(di)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -290,6 +291,13 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.weekindex.date.compute_transform(
|
||||
starting_weekindex,
|
||||
&self.weekindex.first_dateindex,
|
||||
|(wi, first_di, ..)| (wi, Date::from(first_di)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.weekindex.dateindex_count.compute_count_from_indexes(
|
||||
starting_weekindex,
|
||||
&self.weekindex.first_dateindex,
|
||||
@@ -324,6 +332,13 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.monthindex.date.compute_transform(
|
||||
starting_monthindex,
|
||||
&self.monthindex.first_dateindex,
|
||||
|(mi, first_di, ..)| (mi, Date::from(first_di)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.monthindex.dateindex_count.compute_count_from_indexes(
|
||||
starting_monthindex,
|
||||
&self.monthindex.first_dateindex,
|
||||
@@ -357,6 +372,17 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
let monthindex_first_dateindex = &self.monthindex.first_dateindex;
|
||||
self.quarterindex.date.compute_transform(
|
||||
starting_quarterindex,
|
||||
&self.quarterindex.first_monthindex,
|
||||
|(qi, first_mi, _)| {
|
||||
let first_di = monthindex_first_dateindex.iter().get_unwrap(first_mi);
|
||||
(qi, Date::from(first_di))
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.quarterindex
|
||||
.monthindex_count
|
||||
.compute_count_from_indexes(
|
||||
@@ -392,6 +418,17 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
let monthindex_first_dateindex = &self.monthindex.first_dateindex;
|
||||
self.semesterindex.date.compute_transform(
|
||||
starting_semesterindex,
|
||||
&self.semesterindex.first_monthindex,
|
||||
|(si, first_mi, _)| {
|
||||
let first_di = monthindex_first_dateindex.iter().get_unwrap(first_mi);
|
||||
(si, Date::from(first_di))
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.semesterindex
|
||||
.monthindex_count
|
||||
.compute_count_from_indexes(
|
||||
@@ -427,6 +464,17 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
let monthindex_first_dateindex = &self.monthindex.first_dateindex;
|
||||
self.yearindex.date.compute_transform(
|
||||
starting_yearindex,
|
||||
&self.yearindex.first_monthindex,
|
||||
|(yi, first_mi, _)| {
|
||||
let first_di = monthindex_first_dateindex.iter().get_unwrap(first_mi);
|
||||
(yi, Date::from(first_di))
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.yearindex.monthindex_count.compute_count_from_indexes(
|
||||
starting_yearindex,
|
||||
&self.yearindex.first_monthindex,
|
||||
@@ -460,6 +508,19 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
let yearindex_first_monthindex = &self.yearindex.first_monthindex;
|
||||
let monthindex_first_dateindex = &self.monthindex.first_dateindex;
|
||||
self.decadeindex.date.compute_transform(
|
||||
starting_decadeindex,
|
||||
&self.decadeindex.first_yearindex,
|
||||
|(di, first_yi, _)| {
|
||||
let first_mi = yearindex_first_monthindex.iter().get_unwrap(first_yi);
|
||||
let first_di = monthindex_first_dateindex.iter().get_unwrap(first_mi);
|
||||
(di, Date::from(first_di))
|
||||
},
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.decadeindex
|
||||
.yearindex_count
|
||||
.compute_count_from_indexes(
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DateIndex, MonthIndex, QuarterIndex, SemesterIndex, StoredU64, Version, YearIndex};
|
||||
use brk_types::{
|
||||
Date, DateIndex, MonthIndex, QuarterIndex, SemesterIndex, StoredU64, Version, YearIndex,
|
||||
};
|
||||
use vecdb::{Database, EagerVec, ImportableVec, PcoVec};
|
||||
|
||||
use brk_error::Result;
|
||||
@@ -7,6 +9,7 @@ use brk_error::Result;
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub identity: EagerVec<PcoVec<MonthIndex, MonthIndex>>,
|
||||
pub date: EagerVec<PcoVec<MonthIndex, Date>>,
|
||||
pub first_dateindex: EagerVec<PcoVec<MonthIndex, DateIndex>>,
|
||||
pub dateindex_count: EagerVec<PcoVec<MonthIndex, StoredU64>>,
|
||||
pub quarterindex: EagerVec<PcoVec<MonthIndex, QuarterIndex>>,
|
||||
@@ -18,11 +21,12 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "monthindex", version)?,
|
||||
first_dateindex: EagerVec::forced_import(db, "monthindex_first_dateindex", version)?,
|
||||
dateindex_count: EagerVec::forced_import(db, "monthindex_dateindex_count", version)?,
|
||||
quarterindex: EagerVec::forced_import(db, "monthindex_quarterindex", version)?,
|
||||
semesterindex: EagerVec::forced_import(db, "monthindex_semesterindex", version)?,
|
||||
yearindex: EagerVec::forced_import(db, "monthindex_yearindex", version)?,
|
||||
date: EagerVec::forced_import(db, "date", version)?,
|
||||
first_dateindex: EagerVec::forced_import(db, "first_dateindex", version)?,
|
||||
dateindex_count: EagerVec::forced_import(db, "dateindex_count", version)?,
|
||||
quarterindex: EagerVec::forced_import(db, "quarterindex", version)?,
|
||||
semesterindex: EagerVec::forced_import(db, "semesterindex", version)?,
|
||||
yearindex: EagerVec::forced_import(db, "yearindex", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{MonthIndex, QuarterIndex, StoredU64, Version};
|
||||
use brk_types::{Date, MonthIndex, QuarterIndex, StoredU64, Version};
|
||||
use vecdb::{Database, EagerVec, ImportableVec, PcoVec};
|
||||
|
||||
use brk_error::Result;
|
||||
@@ -7,6 +7,7 @@ use brk_error::Result;
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub identity: EagerVec<PcoVec<QuarterIndex, QuarterIndex>>,
|
||||
pub date: EagerVec<PcoVec<QuarterIndex, Date>>,
|
||||
pub first_monthindex: EagerVec<PcoVec<QuarterIndex, MonthIndex>>,
|
||||
pub monthindex_count: EagerVec<PcoVec<QuarterIndex, StoredU64>>,
|
||||
}
|
||||
@@ -15,8 +16,9 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "quarterindex", version)?,
|
||||
first_monthindex: EagerVec::forced_import(db, "quarterindex_first_monthindex", version)?,
|
||||
monthindex_count: EagerVec::forced_import(db, "quarterindex_monthindex_count", version)?,
|
||||
date: EagerVec::forced_import(db, "date", version)?,
|
||||
first_monthindex: EagerVec::forced_import(db, "first_monthindex", version)?,
|
||||
monthindex_count: EagerVec::forced_import(db, "monthindex_count", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{MonthIndex, SemesterIndex, StoredU64, Version};
|
||||
use brk_types::{Date, MonthIndex, SemesterIndex, StoredU64, Version};
|
||||
use vecdb::{Database, EagerVec, ImportableVec, PcoVec};
|
||||
|
||||
use brk_error::Result;
|
||||
@@ -7,6 +7,7 @@ use brk_error::Result;
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub identity: EagerVec<PcoVec<SemesterIndex, SemesterIndex>>,
|
||||
pub date: EagerVec<PcoVec<SemesterIndex, Date>>,
|
||||
pub first_monthindex: EagerVec<PcoVec<SemesterIndex, MonthIndex>>,
|
||||
pub monthindex_count: EagerVec<PcoVec<SemesterIndex, StoredU64>>,
|
||||
}
|
||||
@@ -15,8 +16,9 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "semesterindex", version)?,
|
||||
first_monthindex: EagerVec::forced_import(db, "semesterindex_first_monthindex", version)?,
|
||||
monthindex_count: EagerVec::forced_import(db, "semesterindex_monthindex_count", version)?,
|
||||
date: EagerVec::forced_import(db, "date", version)?,
|
||||
first_monthindex: EagerVec::forced_import(db, "first_monthindex", version)?,
|
||||
monthindex_count: EagerVec::forced_import(db, "monthindex_count", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ impl Vecs {
|
||||
indexer.vecs.transactions.txid.boxed_clone(),
|
||||
|index, _| Some(index),
|
||||
),
|
||||
input_count: EagerVec::forced_import(db, "txindex_input_count", version)?,
|
||||
output_count: EagerVec::forced_import(db, "txindex_output_count", version)?,
|
||||
input_count: EagerVec::forced_import(db, "input_count", version)?,
|
||||
output_count: EagerVec::forced_import(db, "output_count", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DateIndex, StoredU64, Version, WeekIndex};
|
||||
use brk_types::{Date, DateIndex, StoredU64, Version, WeekIndex};
|
||||
use vecdb::{Database, EagerVec, ImportableVec, PcoVec};
|
||||
|
||||
use brk_error::Result;
|
||||
@@ -7,6 +7,7 @@ use brk_error::Result;
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub identity: EagerVec<PcoVec<WeekIndex, WeekIndex>>,
|
||||
pub date: EagerVec<PcoVec<WeekIndex, Date>>,
|
||||
pub first_dateindex: EagerVec<PcoVec<WeekIndex, DateIndex>>,
|
||||
pub dateindex_count: EagerVec<PcoVec<WeekIndex, StoredU64>>,
|
||||
}
|
||||
@@ -15,8 +16,9 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "weekindex", version)?,
|
||||
first_dateindex: EagerVec::forced_import(db, "weekindex_first_dateindex", version)?,
|
||||
dateindex_count: EagerVec::forced_import(db, "weekindex_dateindex_count", version)?,
|
||||
date: EagerVec::forced_import(db, "date", version)?,
|
||||
first_dateindex: EagerVec::forced_import(db, "first_dateindex", version)?,
|
||||
dateindex_count: EagerVec::forced_import(db, "dateindex_count", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DecadeIndex, MonthIndex, StoredU64, Version, YearIndex};
|
||||
use brk_types::{Date, DecadeIndex, MonthIndex, StoredU64, Version, YearIndex};
|
||||
use vecdb::{Database, EagerVec, ImportableVec, PcoVec};
|
||||
|
||||
use brk_error::Result;
|
||||
@@ -7,6 +7,7 @@ use brk_error::Result;
|
||||
#[derive(Clone, Traversable)]
|
||||
pub struct Vecs {
|
||||
pub identity: EagerVec<PcoVec<YearIndex, YearIndex>>,
|
||||
pub date: EagerVec<PcoVec<YearIndex, Date>>,
|
||||
pub first_monthindex: EagerVec<PcoVec<YearIndex, MonthIndex>>,
|
||||
pub monthindex_count: EagerVec<PcoVec<YearIndex, StoredU64>>,
|
||||
pub decadeindex: EagerVec<PcoVec<YearIndex, DecadeIndex>>,
|
||||
@@ -16,9 +17,10 @@ impl Vecs {
|
||||
pub fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
||||
Ok(Self {
|
||||
identity: EagerVec::forced_import(db, "yearindex", version)?,
|
||||
first_monthindex: EagerVec::forced_import(db, "yearindex_first_monthindex", version)?,
|
||||
monthindex_count: EagerVec::forced_import(db, "yearindex_monthindex_count", version)?,
|
||||
decadeindex: EagerVec::forced_import(db, "yearindex_decadeindex", version)?,
|
||||
date: EagerVec::forced_import(db, "date", version)?,
|
||||
first_monthindex: EagerVec::forced_import(db, "first_monthindex", version)?,
|
||||
monthindex_count: EagerVec::forced_import(db, "monthindex_count", version)?,
|
||||
decadeindex: EagerVec::forced_import(db, "decadeindex", version)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user