mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: veccached change
This commit is contained in:
@@ -7,7 +7,7 @@ use crate::{
|
|||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
BlockCountTarget1m, BlockCountTarget1w, BlockCountTarget1y, BlockCountTarget24h,
|
BlockCountTarget1m, BlockCountTarget1w, BlockCountTarget1y, BlockCountTarget24h,
|
||||||
CachedWindowStarts, ConstantVecs, PerBlockCumulativeRolling, Windows,
|
ConstantVecs, PerBlockCumulativeRolling, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
target: Windows {
|
target: Windows {
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ impl Vecs {
|
|||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let v2 = Version::TWO;
|
let v2 = Version::TWO;
|
||||||
|
|
||||||
let hashrate = LazyPerBlock::from_height_source::<DifficultyToHashF64>(
|
let hashrate = LazyPerBlock::from_height_source::<DifficultyToHashF64, _>(
|
||||||
"difficulty_hashrate",
|
"difficulty_hashrate",
|
||||||
version,
|
version,
|
||||||
indexer.vecs.blocks.difficulty.read_only_boxed_clone(),
|
indexer.vecs.blocks.difficulty.read_only_clone(),
|
||||||
indexes,
|
indexes,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ impl Vecs {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
value: Resolutions::forced_import(
|
value: Resolutions::forced_import(
|
||||||
"difficulty",
|
"difficulty",
|
||||||
indexer.vecs.blocks.difficulty.read_only_boxed_clone(),
|
indexer.vecs.blocks.difficulty.read_only_clone(),
|
||||||
version,
|
version,
|
||||||
indexes,
|
indexes,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ impl Vecs {
|
|||||||
let version = parent_version;
|
let version = parent_version;
|
||||||
|
|
||||||
let lookback = LookbackVecs::forced_import(&db, version)?;
|
let lookback = LookbackVecs::forced_import(&db, version)?;
|
||||||
let cached_starts = &lookback.cached_window_starts;
|
let cached_starts = lookback.cached_window_starts();
|
||||||
let count = CountVecs::forced_import(&db, version, indexes, cached_starts)?;
|
let count = CountVecs::forced_import(&db, version, indexes, &cached_starts)?;
|
||||||
let interval = IntervalVecs::forced_import(&db, version, indexes, cached_starts)?;
|
let interval = IntervalVecs::forced_import(&db, version, indexes, &cached_starts)?;
|
||||||
let size = SizeVecs::forced_import(&db, version, indexes, cached_starts)?;
|
let size = SizeVecs::forced_import(&db, version, indexes, &cached_starts)?;
|
||||||
let weight = WeightVecs::forced_import(&db, version, indexes, cached_starts, &size)?;
|
let weight = WeightVecs::forced_import(&db, version, indexes, &cached_starts, &size)?;
|
||||||
let difficulty = DifficultyVecs::forced_import(&db, version, indexer, indexes)?;
|
let difficulty = DifficultyVecs::forced_import(&db, version, indexer, indexes)?;
|
||||||
let halving = HalvingVecs::forced_import(&db, version, indexes)?;
|
let halving = HalvingVecs::forced_import(&db, version, indexes)?;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
|||||||
use super::Vecs;
|
use super::Vecs;
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, PerBlockRollingAverage},
|
internal::{PerBlockRollingAverage, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -13,7 +13,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let interval = PerBlockRollingAverage::forced_import(
|
let interval = PerBlockRollingAverage::forced_import(
|
||||||
db,
|
db,
|
||||||
|
|||||||
@@ -8,17 +8,15 @@ use vecdb::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, WindowStarts, Windows},
|
internal::{WindowStartVec, WindowStarts, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Traversable)]
|
#[derive(Traversable)]
|
||||||
pub struct Vecs<M: StorageMode = Rw> {
|
pub struct Vecs<M: StorageMode = Rw> {
|
||||||
#[traversable(skip)]
|
|
||||||
pub cached_window_starts: CachedWindowStarts,
|
|
||||||
pub _1h: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _1h: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _24h: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 1d
|
pub _24h: CachedVec<M::Stored<EagerVec<PcoVec<Height, Height>>>>, // 1d
|
||||||
pub _3d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _3d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _1w: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 7d
|
pub _1w: CachedVec<M::Stored<EagerVec<PcoVec<Height, Height>>>>, // 7d
|
||||||
pub _8d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _8d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _9d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _9d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _12d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _12d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
@@ -26,7 +24,7 @@ pub struct Vecs<M: StorageMode = Rw> {
|
|||||||
pub _2w: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 14d
|
pub _2w: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 14d
|
||||||
pub _21d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _21d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _26d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _26d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _1m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 30d
|
pub _1m: CachedVec<M::Stored<EagerVec<PcoVec<Height, Height>>>>, // 30d
|
||||||
pub _34d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _34d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _55d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _55d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _2m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 60d
|
pub _2m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 60d
|
||||||
@@ -43,7 +41,7 @@ pub struct Vecs<M: StorageMode = Rw> {
|
|||||||
pub _9m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 270d
|
pub _9m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 270d
|
||||||
pub _350d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
pub _350d: M::Stored<EagerVec<PcoVec<Height, Height>>>,
|
||||||
pub _12m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 360d
|
pub _12m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 360d
|
||||||
pub _1y: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 365d
|
pub _1y: CachedVec<M::Stored<EagerVec<PcoVec<Height, Height>>>>, // 365d
|
||||||
pub _14m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 420d
|
pub _14m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 420d
|
||||||
pub _2y: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 730d
|
pub _2y: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 730d
|
||||||
pub _26m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 780d
|
pub _26m: M::Stored<EagerVec<PcoVec<Height, Height>>>, // 780d
|
||||||
@@ -106,19 +104,11 @@ impl Vecs {
|
|||||||
let _14y = ImportableVec::forced_import(db, "height_14y_ago", version)?;
|
let _14y = ImportableVec::forced_import(db, "height_14y_ago", version)?;
|
||||||
let _26y = ImportableVec::forced_import(db, "height_26y_ago", version)?;
|
let _26y = ImportableVec::forced_import(db, "height_26y_ago", version)?;
|
||||||
|
|
||||||
let cached_window_starts = CachedWindowStarts(Windows {
|
|
||||||
_24h: CachedVec::new(&_24h),
|
|
||||||
_1w: CachedVec::new(&_1w),
|
|
||||||
_1m: CachedVec::new(&_1m),
|
|
||||||
_1y: CachedVec::new(&_1y),
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
cached_window_starts,
|
|
||||||
_1h,
|
_1h,
|
||||||
_24h,
|
_24h: CachedVec::wrap(_24h),
|
||||||
_3d,
|
_3d,
|
||||||
_1w,
|
_1w: CachedVec::wrap(_1w),
|
||||||
_8d,
|
_8d,
|
||||||
_9d,
|
_9d,
|
||||||
_12d,
|
_12d,
|
||||||
@@ -126,7 +116,7 @@ impl Vecs {
|
|||||||
_2w,
|
_2w,
|
||||||
_21d,
|
_21d,
|
||||||
_26d,
|
_26d,
|
||||||
_1m,
|
_1m: CachedVec::wrap(_1m),
|
||||||
_34d,
|
_34d,
|
||||||
_55d,
|
_55d,
|
||||||
_2m,
|
_2m,
|
||||||
@@ -143,7 +133,7 @@ impl Vecs {
|
|||||||
_9m,
|
_9m,
|
||||||
_350d,
|
_350d,
|
||||||
_12m,
|
_12m,
|
||||||
_1y,
|
_1y: CachedVec::wrap(_1y),
|
||||||
_14m,
|
_14m,
|
||||||
_2y,
|
_2y,
|
||||||
_26m,
|
_26m,
|
||||||
@@ -161,8 +151,8 @@ impl Vecs {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_starts(&self) -> WindowStarts<'_> {
|
pub fn cached_window_starts(&self) -> Windows<&WindowStartVec> {
|
||||||
WindowStarts {
|
Windows {
|
||||||
_24h: &self._24h,
|
_24h: &self._24h,
|
||||||
_1w: &self._1w,
|
_1w: &self._1w,
|
||||||
_1m: &self._1m,
|
_1m: &self._1m,
|
||||||
@@ -170,11 +160,20 @@ impl Vecs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn window_starts(&self) -> WindowStarts<'_> {
|
||||||
|
WindowStarts {
|
||||||
|
_24h: &self._24h.inner,
|
||||||
|
_1w: &self._1w.inner,
|
||||||
|
_1m: &self._1m.inner,
|
||||||
|
_1y: &self._1y.inner,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn start_vec(&self, days: usize) -> &EagerVec<PcoVec<Height, Height>> {
|
pub fn start_vec(&self, days: usize) -> &EagerVec<PcoVec<Height, Height>> {
|
||||||
match days {
|
match days {
|
||||||
1 => &self._24h,
|
1 => &self._24h.inner,
|
||||||
3 => &self._3d,
|
3 => &self._3d,
|
||||||
7 => &self._1w,
|
7 => &self._1w.inner,
|
||||||
8 => &self._8d,
|
8 => &self._8d,
|
||||||
9 => &self._9d,
|
9 => &self._9d,
|
||||||
12 => &self._12d,
|
12 => &self._12d,
|
||||||
@@ -182,7 +181,7 @@ impl Vecs {
|
|||||||
14 => &self._2w,
|
14 => &self._2w,
|
||||||
21 => &self._21d,
|
21 => &self._21d,
|
||||||
26 => &self._26d,
|
26 => &self._26d,
|
||||||
30 => &self._1m,
|
30 => &self._1m.inner,
|
||||||
34 => &self._34d,
|
34 => &self._34d,
|
||||||
55 => &self._55d,
|
55 => &self._55d,
|
||||||
60 => &self._2m,
|
60 => &self._2m,
|
||||||
@@ -199,7 +198,7 @@ impl Vecs {
|
|||||||
270 => &self._9m,
|
270 => &self._9m,
|
||||||
350 => &self._350d,
|
350 => &self._350d,
|
||||||
360 => &self._12m,
|
360 => &self._12m,
|
||||||
365 => &self._1y,
|
365 => &self._1y.inner,
|
||||||
420 => &self._14m,
|
420 => &self._14m,
|
||||||
730 => &self._2y,
|
730 => &self._2y,
|
||||||
780 => &self._26m,
|
780 => &self._26m,
|
||||||
@@ -225,9 +224,9 @@ impl Vecs {
|
|||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.compute_rolling_start_hours(indexes, starting_indexes, exit, 1, |s| &mut s._1h)?;
|
self.compute_rolling_start_hours(indexes, starting_indexes, exit, 1, |s| &mut s._1h)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 1, |s| &mut s._24h)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 1, |s| &mut s._24h.inner)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 3, |s| &mut s._3d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 3, |s| &mut s._3d)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 7, |s| &mut s._1w)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 7, |s| &mut s._1w.inner)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 8, |s| &mut s._8d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 8, |s| &mut s._8d)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 9, |s| &mut s._9d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 9, |s| &mut s._9d)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 12, |s| &mut s._12d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 12, |s| &mut s._12d)?;
|
||||||
@@ -235,7 +234,7 @@ impl Vecs {
|
|||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 14, |s| &mut s._2w)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 14, |s| &mut s._2w)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 21, |s| &mut s._21d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 21, |s| &mut s._21d)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 26, |s| &mut s._26d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 26, |s| &mut s._26d)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 30, |s| &mut s._1m)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 30, |s| &mut s._1m.inner)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 34, |s| &mut s._34d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 34, |s| &mut s._34d)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 55, |s| &mut s._55d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 55, |s| &mut s._55d)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 60, |s| &mut s._2m)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 60, |s| &mut s._2m)?;
|
||||||
@@ -252,7 +251,7 @@ impl Vecs {
|
|||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 270, |s| &mut s._9m)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 270, |s| &mut s._9m)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 350, |s| &mut s._350d)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 350, |s| &mut s._350d)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 360, |s| &mut s._12m)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 360, |s| &mut s._12m)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 365, |s| &mut s._1y)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 365, |s| &mut s._1y.inner)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 420, |s| &mut s._14m)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 420, |s| &mut s._14m)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 730, |s| &mut s._2y)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 730, |s| &mut s._2y)?;
|
||||||
self.compute_rolling_start(indexes, starting_indexes, exit, 780, |s| &mut s._26m)?;
|
self.compute_rolling_start(indexes, starting_indexes, exit, 780, |s| &mut s._26m)?;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
|||||||
use super::Vecs;
|
use super::Vecs;
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, PerBlockFull, PerBlockRolling},
|
internal::{PerBlockFull, PerBlockRolling, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -13,7 +13,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
vbytes: PerBlockFull::forced_import(
|
vbytes: PerBlockFull::forced_import(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use super::Vecs;
|
|||||||
use crate::{
|
use crate::{
|
||||||
blocks::SizeVecs,
|
blocks::SizeVecs,
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, LazyPerBlockRolling, PercentVec, VBytesToWeight},
|
internal::{LazyPerBlockRolling, PercentVec, VBytesToWeight, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -14,7 +14,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
size: &SizeVecs,
|
size: &SizeVecs,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let weight = LazyPerBlockRolling::from_per_block_full::<VBytesToWeight>(
|
let weight = LazyPerBlockRolling::from_per_block_full::<VBytesToWeight>(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use super::Vecs;
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, LazyPerBlock, OneMinusF64, PerBlock, PerBlockCumulativeRolling,
|
LazyPerBlock, OneMinusF64, PerBlock, PerBlockCumulativeRolling, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let liveliness = PerBlock::forced_import(db, "liveliness", version, indexes)?;
|
let liveliness = PerBlock::forced_import(db, "liveliness", version, indexes)?;
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ use super::{
|
|||||||
ValueVecs, Vecs,
|
ValueVecs, Vecs,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::internal::CachedWindowStarts;
|
use crate::internal::{WindowStartVec, Windows};
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
pub(crate) fn forced_import(
|
pub(crate) fn forced_import(
|
||||||
parent_path: &Path,
|
parent_path: &Path,
|
||||||
parent_version: Version,
|
parent_version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let db = open_db(parent_path, DB_NAME, 250_000)?;
|
let db = open_db(parent_path, DB_NAME, 250_000)?;
|
||||||
let version = parent_version;
|
let version = parent_version;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ impl Vecs {
|
|||||||
|
|
||||||
self.hodl_bank.compute_cumulative_transformed_binary(
|
self.hodl_bank.compute_cumulative_transformed_binary(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_usd,
|
&prices.spot.usd.height,
|
||||||
&self.vocdd_median_1y,
|
&self.vocdd_median_1y,
|
||||||
|price, median| StoredF64::from(f64::from(price) - f64::from(median)),
|
|price, median| StoredF64::from(f64::from(price) - f64::from(median)),
|
||||||
exit,
|
exit,
|
||||||
@@ -31,7 +31,7 @@ impl Vecs {
|
|||||||
|
|
||||||
self.value.height.compute_divide(
|
self.value.height.compute_divide(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_usd,
|
&prices.spot.usd.height,
|
||||||
&self.hodl_bank,
|
&self.hodl_bank,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ impl Vecs {
|
|||||||
.compute(starting_indexes.height, exit, |vec| {
|
.compute(starting_indexes.height, exit, |vec| {
|
||||||
vec.compute_multiply(
|
vec.compute_multiply(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_usd,
|
&prices.spot.usd.height,
|
||||||
&coinblocks_destroyed.block,
|
&coinblocks_destroyed.block,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -34,7 +34,7 @@ impl Vecs {
|
|||||||
self.created.compute(starting_indexes.height, exit, |vec| {
|
self.created.compute(starting_indexes.height, exit, |vec| {
|
||||||
vec.compute_multiply(
|
vec.compute_multiply(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_usd,
|
&prices.spot.usd.height,
|
||||||
&activity.coinblocks_created.block,
|
&activity.coinblocks_created.block,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -44,7 +44,7 @@ impl Vecs {
|
|||||||
self.stored.compute(starting_indexes.height, exit, |vec| {
|
self.stored.compute(starting_indexes.height, exit, |vec| {
|
||||||
vec.compute_multiply(
|
vec.compute_multiply(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_usd,
|
&prices.spot.usd.height,
|
||||||
&activity.coinblocks_stored.block,
|
&activity.coinblocks_stored.block,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -57,7 +57,7 @@ impl Vecs {
|
|||||||
self.vocdd.compute(starting_indexes.height, exit, |vec| {
|
self.vocdd.compute(starting_indexes.height, exit, |vec| {
|
||||||
vec.compute_transform3(
|
vec.compute_transform3(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_usd,
|
&prices.spot.usd.height,
|
||||||
&coindays_destroyed.block,
|
&coindays_destroyed.block,
|
||||||
circulating_supply,
|
circulating_supply,
|
||||||
|(i, price, cdd, supply, _): (_, Dollars, StoredF64, Bitcoin, _)| {
|
|(i, price, cdd, supply, _): (_, Dollars, StoredF64, Bitcoin, _)| {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
|||||||
use super::Vecs;
|
use super::Vecs;
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, PerBlockCumulativeRolling},
|
internal::{PerBlockCumulativeRolling, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -13,7 +13,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
destroyed: PerBlockCumulativeRolling::forced_import(
|
destroyed: PerBlockCumulativeRolling::forced_import(
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, PerBlockRollingAverage},
|
internal::{PerBlockRollingAverage, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Per-block activity counts - reset each block.
|
/// Per-block activity counts - reset each block.
|
||||||
@@ -77,7 +77,7 @@ impl ActivityCountVecs {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
reactivated: PerBlockRollingAverage::forced_import(
|
reactivated: PerBlockRollingAverage::forced_import(
|
||||||
@@ -174,7 +174,7 @@ impl AddrTypeToActivityCountVecs {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self::from(ByAddrType::<ActivityCountVecs>::new_with_name(
|
Ok(Self::from(ByAddrType::<ActivityCountVecs>::new_with_name(
|
||||||
|type_name| {
|
|type_name| {
|
||||||
@@ -246,7 +246,7 @@ impl AddrActivityVecs {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
all: ActivityCountVecs::forced_import(db, name, version, indexes, cached_starts)?,
|
all: ActivityCountVecs::forced_import(db, name, version, indexes, cached_starts)?,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use brk_types::{BasisPointsSigned32, StoredI64, StoredU64, Version};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, LazyRollingDeltasFromHeight},
|
internal::{LazyRollingDeltasFromHeight, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::AddrCountsVecs;
|
use super::AddrCountsVecs;
|
||||||
@@ -22,7 +22,7 @@ impl DeltaVecs {
|
|||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
version: Version,
|
version: Version,
|
||||||
addr_count: &AddrCountsVecs,
|
addr_count: &AddrCountsVecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let version = version + Version::TWO;
|
let version = version + Version::TWO;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use vecdb::{Database, Exit, Rw, StorageMode};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, PerBlockCumulativeRolling},
|
internal::{PerBlockCumulativeRolling, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::TotalAddrCountVecs;
|
use super::TotalAddrCountVecs;
|
||||||
@@ -24,7 +24,7 @@ impl NewAddrCountVecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let all = PerBlockCumulativeRolling::forced_import(
|
let all = PerBlockCumulativeRolling::forced_import(
|
||||||
db,
|
db,
|
||||||
|
|||||||
@@ -8,7 +8,12 @@ use derive_more::{Deref, DerefMut};
|
|||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use vecdb::{AnyStoredVec, Database, Exit, ReadableVec, Rw, StorageMode};
|
use vecdb::{AnyStoredVec, Database, Exit, ReadableVec, Rw, StorageMode};
|
||||||
|
|
||||||
use crate::{distribution::DynCohortVecs, indexes, internal::CachedWindowStarts, prices};
|
use crate::{
|
||||||
|
distribution::DynCohortVecs,
|
||||||
|
indexes,
|
||||||
|
internal::{WindowStartVec, Windows},
|
||||||
|
prices,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{super::traits::CohortVecs, vecs::AddrCohortVecs};
|
use super::{super::traits::CohortVecs, vecs::AddrCohortVecs};
|
||||||
|
|
||||||
@@ -25,7 +30,7 @@ impl AddrCohorts {
|
|||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
states_path: &Path,
|
states_path: &Path,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let v = version + VERSION;
|
let v = version + VERSION;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use vecdb::{AnyStoredVec, AnyVec, Database, Exit, ReadableVec, Rw, StorageMode,
|
|||||||
use crate::{
|
use crate::{
|
||||||
distribution::state::{AddrCohortState, MinimalRealizedState},
|
distribution::state::{AddrCohortState, MinimalRealizedState},
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, PerBlockWithDeltas},
|
internal::{PerBlockWithDeltas, WindowStartVec, Windows},
|
||||||
prices,
|
prices,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ impl AddrCohortVecs {
|
|||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
states_path: Option<&Path>,
|
states_path: Option<&Path>,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let full_name = CohortContext::Addr.full_name(&filter, name);
|
let full_name = CohortContext::Addr.full_name(&filter, name);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use crate::{
|
|||||||
state::UTXOCohortState,
|
state::UTXOCohortState,
|
||||||
},
|
},
|
||||||
indexes,
|
indexes,
|
||||||
internal::{AmountPerBlockCumulativeRolling, CachedWindowStarts},
|
internal::{AmountPerBlockCumulativeRolling, WindowStartVec, Windows},
|
||||||
prices,
|
prices,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ impl UTXOCohorts<Rw> {
|
|||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
states_path: &Path,
|
states_path: &Path,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let v = version + VERSION;
|
let v = version + VERSION;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use brk_error::Result;
|
|||||||
use brk_traversable::Traversable;
|
use brk_traversable::Traversable;
|
||||||
use brk_types::{Indexes, StoredF32, StoredF64, Version};
|
use brk_types::{Indexes, StoredF32, StoredF64, Version};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, Rw, StorageMode};
|
use vecdb::{AnyStoredVec, Exit, Rw, StorageMode};
|
||||||
|
|
||||||
use crate::internal::{Identity, LazyPerBlock, PerBlock, Windows};
|
use crate::internal::{Identity, LazyPerBlock, PerBlock, Windows};
|
||||||
|
|
||||||
@@ -33,15 +33,10 @@ impl ActivityFull {
|
|||||||
let v1 = Version::ONE;
|
let v1 = Version::ONE;
|
||||||
let inner = ActivityCore::forced_import(cfg)?;
|
let inner = ActivityCore::forced_import(cfg)?;
|
||||||
|
|
||||||
let coinyears_destroyed = LazyPerBlock::from_height_source::<Identity<StoredF64>>(
|
let coinyears_destroyed = LazyPerBlock::from_height_source::<Identity<StoredF64>, _>(
|
||||||
&cfg.name("coinyears_destroyed"),
|
&cfg.name("coinyears_destroyed"),
|
||||||
cfg.version + v1,
|
cfg.version + v1,
|
||||||
inner
|
inner.coindays_destroyed.sum._1y.height.clone(),
|
||||||
.coindays_destroyed
|
|
||||||
.sum
|
|
||||||
._1y
|
|
||||||
.height
|
|
||||||
.read_only_boxed_clone(),
|
|
||||||
cfg.indexes,
|
cfg.indexes,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ impl AllCohortMetrics {
|
|||||||
|
|
||||||
self.unrealized.compute(
|
self.unrealized.compute(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized.price.cents.height,
|
&self.realized.price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -139,7 +139,7 @@ impl AllCohortMetrics {
|
|||||||
|
|
||||||
self.cost_basis.compute_prices(
|
self.cost_basis.compute_prices(
|
||||||
starting_indexes,
|
starting_indexes,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.unrealized.invested_capital.in_profit.cents.height,
|
&self.unrealized.invested_capital.in_profit.cents.height,
|
||||||
&self.unrealized.invested_capital.in_loss.cents.height,
|
&self.unrealized.invested_capital.in_loss.cents.height,
|
||||||
&self.supply.in_profit.sats.height,
|
&self.supply.in_profit.sats.height,
|
||||||
@@ -150,7 +150,7 @@ impl AllCohortMetrics {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.unrealized
|
self.unrealized
|
||||||
.compute_sentiment(starting_indexes, &prices.cached_spot_cents, exit)?;
|
.compute_sentiment(starting_indexes, &prices.spot.cents.height, exit)?;
|
||||||
|
|
||||||
self.relative.compute(
|
self.relative.compute(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ impl BasicCohortMetrics {
|
|||||||
|
|
||||||
self.unrealized.compute(
|
self.unrealized.compute(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized.price.cents.height,
|
&self.realized.price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ impl CoreCohortMetrics {
|
|||||||
|
|
||||||
self.unrealized.compute(
|
self.unrealized.compute(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized.price.cents.height,
|
&self.realized.price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -108,14 +108,14 @@ impl ExtendedCohortMetrics {
|
|||||||
|
|
||||||
self.unrealized.compute(
|
self.unrealized.compute(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized.price.cents.height,
|
&self.realized.price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.cost_basis.compute_prices(
|
self.cost_basis.compute_prices(
|
||||||
starting_indexes,
|
starting_indexes,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.unrealized.invested_capital.in_profit.cents.height,
|
&self.unrealized.invested_capital.in_profit.cents.height,
|
||||||
&self.unrealized.invested_capital.in_loss.cents.height,
|
&self.unrealized.invested_capital.in_loss.cents.height,
|
||||||
&self.supply.in_profit.sats.height,
|
&self.supply.in_profit.sats.height,
|
||||||
@@ -126,7 +126,7 @@ impl ExtendedCohortMetrics {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.unrealized
|
self.unrealized
|
||||||
.compute_sentiment(starting_indexes, &prices.cached_spot_cents, exit)?;
|
.compute_sentiment(starting_indexes, &prices.spot.cents.height, exit)?;
|
||||||
|
|
||||||
self.relative.compute(
|
self.relative.compute(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ impl MinimalCohortMetrics {
|
|||||||
|
|
||||||
self.unrealized.compute(
|
self.unrealized.compute(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized.price.cents.height,
|
&self.realized.price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ impl TypeCohortMetrics {
|
|||||||
|
|
||||||
self.unrealized.compute(
|
self.unrealized.compute(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized.price.cents.height,
|
&self.realized.price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ use vecdb::{BytesVec, BytesVecValue, Database, ImportableVec};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
AmountPerBlock, AmountPerBlockCumulative, AmountPerBlockCumulativeRolling,
|
AmountPerBlock, AmountPerBlockCumulative, AmountPerBlockCumulativeRolling, CentsType,
|
||||||
CachedWindowStarts, CentsType, FiatPerBlock, FiatPerBlockCumulativeWithSums, NumericValue,
|
FiatPerBlock, FiatPerBlockCumulativeWithSums, NumericValue, PerBlock,
|
||||||
PerBlock, PerBlockCumulativeRolling, PercentPerBlock, PercentRollingWindows, Price,
|
PerBlockCumulativeRolling, PercentPerBlock, PercentRollingWindows, Price,
|
||||||
PriceWithRatioExtendedPerBlock, PriceWithRatioPerBlock, RatioPerBlock,
|
PriceWithRatioExtendedPerBlock, PriceWithRatioPerBlock, RatioPerBlock,
|
||||||
RollingWindow24hPerBlock, RollingWindows, RollingWindowsFrom1w,
|
RollingWindow24hPerBlock, RollingWindows, RollingWindowsFrom1w, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ pub struct ImportConfig<'a> {
|
|||||||
pub full_name: &'a str,
|
pub full_name: &'a str,
|
||||||
pub version: Version,
|
pub version: Version,
|
||||||
pub indexes: &'a indexes::Vecs,
|
pub indexes: &'a indexes::Vecs,
|
||||||
pub cached_starts: &'a CachedWindowStarts,
|
pub cached_starts: &'a Windows<&'a WindowStartVec>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ImportConfig<'a> {
|
impl<'a> ImportConfig<'a> {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
AmountPerBlock, AmountPerBlockWithDeltas, CachedWindowStarts, PerBlock, RatioPerBlock,
|
AmountPerBlock, AmountPerBlockWithDeltas, PerBlock, RatioPerBlock, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
prices,
|
prices,
|
||||||
};
|
};
|
||||||
@@ -43,7 +43,7 @@ impl ProfitabilityBucket {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
supply: WithSth {
|
supply: WithSth {
|
||||||
@@ -126,7 +126,7 @@ impl ProfitabilityBucket {
|
|||||||
|
|
||||||
self.unrealized_pnl.all.height.compute_transform3(
|
self.unrealized_pnl.all.height.compute_transform3(
|
||||||
max_from,
|
max_from,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized_cap.all.height,
|
&self.realized_cap.all.height,
|
||||||
&self.supply.all.sats.height,
|
&self.supply.all.sats.height,
|
||||||
|(i, spot, cap, supply, ..)| {
|
|(i, spot, cap, supply, ..)| {
|
||||||
@@ -139,7 +139,7 @@ impl ProfitabilityBucket {
|
|||||||
)?;
|
)?;
|
||||||
self.unrealized_pnl.sth.height.compute_transform3(
|
self.unrealized_pnl.sth.height.compute_transform3(
|
||||||
max_from,
|
max_from,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized_cap.sth.height,
|
&self.realized_cap.sth.height,
|
||||||
&self.supply.sth.sats.height,
|
&self.supply.sth.sats.height,
|
||||||
|(i, spot, cap, supply, ..)| {
|
|(i, spot, cap, supply, ..)| {
|
||||||
@@ -153,7 +153,7 @@ impl ProfitabilityBucket {
|
|||||||
|
|
||||||
self.nupl.bps.height.compute_transform3(
|
self.nupl.bps.height.compute_transform3(
|
||||||
max_from,
|
max_from,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.realized_cap.all.height,
|
&self.realized_cap.all.height,
|
||||||
&self.supply.all.sats.height,
|
&self.supply.all.sats.height,
|
||||||
|(i, spot, cap_dollars, supply_sats, ..)| {
|
|(i, spot, cap_dollars, supply_sats, ..)| {
|
||||||
@@ -267,7 +267,7 @@ impl ProfitabilityMetrics {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let range = ProfitabilityRange::try_new(|name| {
|
let range = ProfitabilityRange::try_new(|name| {
|
||||||
ProfitabilityBucket::forced_import(db, name, version, indexes, cached_starts)
|
ProfitabilityBucket::forced_import(db, name, version, indexes, cached_starts)
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ impl RealizedCore {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let neg_loss_sum = minimal.loss.sum.0.map_with_suffix(|suffix, slot| {
|
let neg_loss_sum = minimal.loss.sum.0.map_with_suffix(|suffix, slot| {
|
||||||
LazyPerBlock::from_height_source::<NegCentsUnsignedToDollars>(
|
LazyPerBlock::from_height_source::<NegCentsUnsignedToDollars, _>(
|
||||||
&cfg.name(&format!("realized_loss_neg_sum_{suffix}")),
|
&cfg.name(&format!("realized_loss_neg_sum_{suffix}")),
|
||||||
cfg.version + Version::ONE,
|
cfg.version + Version::ONE,
|
||||||
slot.cents.height.read_only_boxed_clone(),
|
slot.cents.height.clone(),
|
||||||
cfg.indexes,
|
cfg.indexes,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ impl UnrealizedFull {
|
|||||||
.compute_transform3(
|
.compute_transform3(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
supply_in_profit_sats,
|
supply_in_profit_sats,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.inner.basic.profit.cents.height,
|
&self.inner.basic.profit.cents.height,
|
||||||
|(h, supply_sats, spot, profit, ..): (_, Sats, Cents, Cents, _)| {
|
|(h, supply_sats, spot, profit, ..): (_, Sats, Cents, Cents, _)| {
|
||||||
let market_value = supply_sats.as_u128() * spot.as_u128() / Sats::ONE_BTC_U128;
|
let market_value = supply_sats.as_u128() * spot.as_u128() / Sats::ONE_BTC_U128;
|
||||||
@@ -142,7 +142,7 @@ impl UnrealizedFull {
|
|||||||
.compute_transform3(
|
.compute_transform3(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
supply_in_loss_sats,
|
supply_in_loss_sats,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.inner.basic.loss.cents.height,
|
&self.inner.basic.loss.cents.height,
|
||||||
|(h, supply_sats, spot, loss, ..): (_, Sats, Cents, Cents, _)| {
|
|(h, supply_sats, spot, loss, ..): (_, Sats, Cents, Cents, _)| {
|
||||||
let market_value = supply_sats.as_u128() * spot.as_u128() / Sats::ONE_BTC_U128;
|
let market_value = supply_sats.as_u128() * spot.as_u128() / Sats::ONE_BTC_U128;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
indexes, inputs,
|
indexes, inputs,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, PerBlockCumulativeRolling,
|
PerBlockCumulativeRolling, WindowStartVec, Windows,
|
||||||
db_utils::{finalize_db, open_db},
|
db_utils::{finalize_db, open_db},
|
||||||
},
|
},
|
||||||
outputs, prices, transactions,
|
outputs, prices, transactions,
|
||||||
@@ -102,7 +102,7 @@ impl Vecs {
|
|||||||
parent: &Path,
|
parent: &Path,
|
||||||
parent_version: Version,
|
parent_version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let db_path = parent.join(super::DB_NAME);
|
let db_path = parent.join(super::DB_NAME);
|
||||||
let states_path = db_path.join("states");
|
let states_path = db_path.join("states");
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
use brk_types::{
|
|
||||||
Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3,
|
|
||||||
Month6, Week1, Year1, Year10,
|
|
||||||
};
|
|
||||||
use vecdb::CachedVec;
|
|
||||||
|
|
||||||
use super::Vecs;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct CachedMappings {
|
|
||||||
pub minute10_first_height: CachedVec<Minute10, Height>,
|
|
||||||
pub minute30_first_height: CachedVec<Minute30, Height>,
|
|
||||||
pub hour1_first_height: CachedVec<Hour1, Height>,
|
|
||||||
pub hour4_first_height: CachedVec<Hour4, Height>,
|
|
||||||
pub hour12_first_height: CachedVec<Hour12, Height>,
|
|
||||||
pub day1_first_height: CachedVec<Day1, Height>,
|
|
||||||
pub day3_first_height: CachedVec<Day3, Height>,
|
|
||||||
pub week1_first_height: CachedVec<Week1, Height>,
|
|
||||||
pub month1_first_height: CachedVec<Month1, Height>,
|
|
||||||
pub month3_first_height: CachedVec<Month3, Height>,
|
|
||||||
pub month6_first_height: CachedVec<Month6, Height>,
|
|
||||||
pub year1_first_height: CachedVec<Year1, Height>,
|
|
||||||
pub year10_first_height: CachedVec<Year10, Height>,
|
|
||||||
pub halving_identity: CachedVec<Halving, Halving>,
|
|
||||||
pub epoch_identity: CachedVec<Epoch, Epoch>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CachedMappings {
|
|
||||||
pub fn new(vecs: &Vecs) -> Self {
|
|
||||||
Self {
|
|
||||||
minute10_first_height: CachedVec::new(&vecs.minute10.first_height),
|
|
||||||
minute30_first_height: CachedVec::new(&vecs.minute30.first_height),
|
|
||||||
hour1_first_height: CachedVec::new(&vecs.hour1.first_height),
|
|
||||||
hour4_first_height: CachedVec::new(&vecs.hour4.first_height),
|
|
||||||
hour12_first_height: CachedVec::new(&vecs.hour12.first_height),
|
|
||||||
day1_first_height: CachedVec::new(&vecs.day1.first_height),
|
|
||||||
day3_first_height: CachedVec::new(&vecs.day3.first_height),
|
|
||||||
week1_first_height: CachedVec::new(&vecs.week1.first_height),
|
|
||||||
month1_first_height: CachedVec::new(&vecs.month1.first_height),
|
|
||||||
month3_first_height: CachedVec::new(&vecs.month3.first_height),
|
|
||||||
month6_first_height: CachedVec::new(&vecs.month6.first_height),
|
|
||||||
year1_first_height: CachedVec::new(&vecs.year1.first_height),
|
|
||||||
year10_first_height: CachedVec::new(&vecs.year10.first_height),
|
|
||||||
halving_identity: CachedVec::new(&vecs.halving.identity),
|
|
||||||
epoch_identity: CachedVec::new(&vecs.epoch.identity),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use brk_traversable::Traversable;
|
use brk_traversable::Traversable;
|
||||||
use brk_types::{Date, Day1, Height, StoredU64, Version};
|
use brk_types::{Date, Day1, Height, Version};
|
||||||
use vecdb::{Database, EagerVec, ImportableVec, PcoVec, Rw, StorageMode};
|
use vecdb::{CachedVec, Database, EagerVec, ImportableVec, PcoVec, Rw, StorageMode};
|
||||||
|
|
||||||
use brk_error::Result;
|
use brk_error::Result;
|
||||||
|
|
||||||
@@ -8,8 +8,7 @@ use brk_error::Result;
|
|||||||
pub struct Vecs<M: StorageMode = Rw> {
|
pub struct Vecs<M: StorageMode = Rw> {
|
||||||
pub identity: M::Stored<EagerVec<PcoVec<Day1, Day1>>>,
|
pub identity: M::Stored<EagerVec<PcoVec<Day1, Day1>>>,
|
||||||
pub date: M::Stored<EagerVec<PcoVec<Day1, Date>>>,
|
pub date: M::Stored<EagerVec<PcoVec<Day1, Date>>>,
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Day1, Height>>>,
|
pub first_height: CachedVec<M::Stored<EagerVec<PcoVec<Day1, Height>>>>,
|
||||||
pub height_count: M::Stored<EagerVec<PcoVec<Day1, StoredU64>>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -17,8 +16,7 @@ impl Vecs {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
identity: EagerVec::forced_import(db, "day1_index", version)?,
|
identity: EagerVec::forced_import(db, "day1_index", version)?,
|
||||||
date: EagerVec::forced_import(db, "date", version + Version::ONE)?,
|
date: EagerVec::forced_import(db, "date", version + Version::ONE)?,
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
first_height: CachedVec::wrap(EagerVec::forced_import(db, "first_height", version)?),
|
||||||
height_count: EagerVec::forced_import(db, "height_count", version)?,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Day3, Height, 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<Day3, Day3>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Day3, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "day3_index", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Epoch, Height, StoredU64, 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<Epoch, Epoch>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Epoch, Height>>>,
|
|
||||||
pub height_count: M::Stored<EagerVec<PcoVec<Epoch, StoredU64>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "epoch", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
height_count: EagerVec::forced_import(db, "height_count", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Halving, Height, 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<Halving, Halving>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Halving, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "halving", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Height, Hour1, 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<Hour1, Hour1>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Hour1, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "hour1_index", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Height, Hour12, 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<Hour12, Hour12>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Hour12, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "hour12_index", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Height, Hour4, 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<Hour4, Hour4>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Hour4, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "hour4_index", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Height, Minute10, 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<Minute10, Minute10>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Minute10, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "minute10_index", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Height, Minute30, 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<Minute30, Minute30>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Minute30, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "minute30_index", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +1,12 @@
|
|||||||
mod addr;
|
mod addr;
|
||||||
mod cached_mappings;
|
|
||||||
mod day1;
|
mod day1;
|
||||||
mod day3;
|
|
||||||
mod epoch;
|
|
||||||
mod halving;
|
|
||||||
mod height;
|
mod height;
|
||||||
mod hour1;
|
mod resolution;
|
||||||
mod hour12;
|
|
||||||
mod hour4;
|
|
||||||
mod minute10;
|
|
||||||
mod minute30;
|
|
||||||
mod month1;
|
|
||||||
mod month3;
|
|
||||||
mod month6;
|
|
||||||
pub mod timestamp;
|
pub mod timestamp;
|
||||||
mod tx_heights;
|
mod tx_heights;
|
||||||
mod tx_index;
|
mod tx_index;
|
||||||
mod txin_index;
|
mod txin_index;
|
||||||
mod txout_index;
|
mod txout_index;
|
||||||
mod week1;
|
|
||||||
mod year1;
|
|
||||||
mod year10;
|
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
@@ -28,36 +14,37 @@ use brk_error::Result;
|
|||||||
use brk_indexer::Indexer;
|
use brk_indexer::Indexer;
|
||||||
use brk_traversable::Traversable;
|
use brk_traversable::Traversable;
|
||||||
use brk_types::{
|
use brk_types::{
|
||||||
Date, Day1, Day3, Height, Hour1, Hour4, Hour12, Indexes, Minute10, Minute30, Month1, Month3,
|
Date, Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Indexes, Minute10, Minute30,
|
||||||
Month6, Version, Week1, Year1, Year10,
|
Month1, Month3, Month6, Version, Week1, Year1, Year10,
|
||||||
};
|
};
|
||||||
use vecdb::{CachedVec, Database, Exit, ReadableVec, Rw, StorageMode};
|
use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode};
|
||||||
|
|
||||||
use crate::internal::db_utils::{finalize_db, open_db};
|
use crate::internal::db_utils::{finalize_db, open_db};
|
||||||
|
|
||||||
pub use addr::Vecs as AddrVecs;
|
pub use addr::Vecs as AddrVecs;
|
||||||
pub use cached_mappings::CachedMappings;
|
|
||||||
pub use day1::Vecs as Day1Vecs;
|
pub use day1::Vecs as Day1Vecs;
|
||||||
pub use day3::Vecs as Day3Vecs;
|
|
||||||
pub use epoch::Vecs as EpochVecs;
|
|
||||||
pub use halving::Vecs as HalvingVecs;
|
|
||||||
pub use height::Vecs as HeightVecs;
|
pub use height::Vecs as HeightVecs;
|
||||||
pub use hour1::Vecs as Hour1Vecs;
|
pub use resolution::{CachedResolutionVecs, DatedResolutionVecs, ResolutionVecs};
|
||||||
pub use hour4::Vecs as Hour4Vecs;
|
|
||||||
pub use hour12::Vecs as Hour12Vecs;
|
|
||||||
pub use minute10::Vecs as Minute10Vecs;
|
|
||||||
pub use minute30::Vecs as Minute30Vecs;
|
|
||||||
pub use month1::Vecs as Month1Vecs;
|
|
||||||
pub use month3::Vecs as Month3Vecs;
|
|
||||||
pub use month6::Vecs as Month6Vecs;
|
|
||||||
pub use timestamp::Timestamps;
|
pub use timestamp::Timestamps;
|
||||||
pub use tx_heights::TxHeights;
|
pub use tx_heights::TxHeights;
|
||||||
pub use tx_index::Vecs as TxIndexVecs;
|
pub use tx_index::Vecs as TxIndexVecs;
|
||||||
pub use txin_index::Vecs as TxInIndexVecs;
|
pub use txin_index::Vecs as TxInIndexVecs;
|
||||||
pub use txout_index::Vecs as TxOutIndexVecs;
|
pub use txout_index::Vecs as TxOutIndexVecs;
|
||||||
pub use week1::Vecs as Week1Vecs;
|
|
||||||
pub use year1::Vecs as Year1Vecs;
|
pub type Minute10Vecs<M = Rw> = ResolutionVecs<Minute10, M>;
|
||||||
pub use year10::Vecs as Year10Vecs;
|
pub type Minute30Vecs<M = Rw> = ResolutionVecs<Minute30, M>;
|
||||||
|
pub type Hour1Vecs<M = Rw> = ResolutionVecs<Hour1, M>;
|
||||||
|
pub type Hour4Vecs<M = Rw> = ResolutionVecs<Hour4, M>;
|
||||||
|
pub type Hour12Vecs<M = Rw> = ResolutionVecs<Hour12, M>;
|
||||||
|
pub type Day3Vecs<M = Rw> = ResolutionVecs<Day3, M>;
|
||||||
|
pub type EpochVecs<M = Rw> = CachedResolutionVecs<Epoch, M>;
|
||||||
|
pub type HalvingVecs<M = Rw> = CachedResolutionVecs<Halving, M>;
|
||||||
|
pub type Week1Vecs<M = Rw> = DatedResolutionVecs<Week1, M>;
|
||||||
|
pub type Month1Vecs<M = Rw> = DatedResolutionVecs<Month1, M>;
|
||||||
|
pub type Month3Vecs<M = Rw> = DatedResolutionVecs<Month3, M>;
|
||||||
|
pub type Month6Vecs<M = Rw> = DatedResolutionVecs<Month6, M>;
|
||||||
|
pub type Year1Vecs<M = Rw> = DatedResolutionVecs<Year1, M>;
|
||||||
|
pub type Year10Vecs<M = Rw> = DatedResolutionVecs<Year10, M>;
|
||||||
|
|
||||||
pub const DB_NAME: &str = "indexes";
|
pub const DB_NAME: &str = "indexes";
|
||||||
|
|
||||||
@@ -65,8 +52,6 @@ pub const DB_NAME: &str = "indexes";
|
|||||||
pub struct Vecs<M: StorageMode = Rw> {
|
pub struct Vecs<M: StorageMode = Rw> {
|
||||||
db: Database,
|
db: Database,
|
||||||
#[traversable(skip)]
|
#[traversable(skip)]
|
||||||
pub cached_mappings: CachedMappings,
|
|
||||||
#[traversable(skip)]
|
|
||||||
pub tx_heights: TxHeights,
|
pub tx_heights: TxHeights,
|
||||||
pub addr: AddrVecs,
|
pub addr: AddrVecs,
|
||||||
pub height: HeightVecs<M>,
|
pub height: HeightVecs<M>,
|
||||||
@@ -103,50 +88,31 @@ impl Vecs {
|
|||||||
|
|
||||||
let addr = AddrVecs::forced_import(version, indexer);
|
let addr = AddrVecs::forced_import(version, indexer);
|
||||||
let height = HeightVecs::forced_import(&db, version)?;
|
let height = HeightVecs::forced_import(&db, version)?;
|
||||||
let epoch = EpochVecs::forced_import(&db, version)?;
|
let epoch = CachedResolutionVecs::forced_import(&db, "epoch", version)?;
|
||||||
let halving = HalvingVecs::forced_import(&db, version)?;
|
let halving = CachedResolutionVecs::forced_import(&db, "halving", version)?;
|
||||||
let minute10 = Minute10Vecs::forced_import(&db, version)?;
|
let minute10 = ResolutionVecs::forced_import(&db, "minute10_index", version)?;
|
||||||
let minute30 = Minute30Vecs::forced_import(&db, version)?;
|
let minute30 = ResolutionVecs::forced_import(&db, "minute30_index", version)?;
|
||||||
let hour1 = Hour1Vecs::forced_import(&db, version)?;
|
let hour1 = ResolutionVecs::forced_import(&db, "hour1_index", version)?;
|
||||||
let hour4 = Hour4Vecs::forced_import(&db, version)?;
|
let hour4 = ResolutionVecs::forced_import(&db, "hour4_index", version)?;
|
||||||
let hour12 = Hour12Vecs::forced_import(&db, version)?;
|
let hour12 = ResolutionVecs::forced_import(&db, "hour12_index", version)?;
|
||||||
let day1 = Day1Vecs::forced_import(&db, version)?;
|
let day1 = Day1Vecs::forced_import(&db, version)?;
|
||||||
let day3 = Day3Vecs::forced_import(&db, version)?;
|
let day3 = ResolutionVecs::forced_import(&db, "day3_index", version)?;
|
||||||
let week1 = Week1Vecs::forced_import(&db, version)?;
|
let week1 = DatedResolutionVecs::forced_import(&db, "week1_index", version)?;
|
||||||
let month1 = Month1Vecs::forced_import(&db, version)?;
|
let month1 = DatedResolutionVecs::forced_import(&db, "month1_index", version)?;
|
||||||
let month3 = Month3Vecs::forced_import(&db, version)?;
|
let month3 = DatedResolutionVecs::forced_import(&db, "month3_index", version)?;
|
||||||
let month6 = Month6Vecs::forced_import(&db, version)?;
|
let month6 = DatedResolutionVecs::forced_import(&db, "month6_index", version)?;
|
||||||
let year1 = Year1Vecs::forced_import(&db, version)?;
|
let year1 = DatedResolutionVecs::forced_import(&db, "year1_index", version)?;
|
||||||
let year10 = Year10Vecs::forced_import(&db, version)?;
|
let year10 = DatedResolutionVecs::forced_import(&db, "year10_index", version)?;
|
||||||
let tx_index = TxIndexVecs::forced_import(&db, version, indexer)?;
|
let tx_index = TxIndexVecs::forced_import(&db, version, indexer)?;
|
||||||
let txin_index = TxInIndexVecs::forced_import(version, indexer);
|
let txin_index = TxInIndexVecs::forced_import(version, indexer);
|
||||||
let txout_index = TxOutIndexVecs::forced_import(version, indexer);
|
let txout_index = TxOutIndexVecs::forced_import(version, indexer);
|
||||||
|
|
||||||
let cached_mappings = CachedMappings {
|
|
||||||
minute10_first_height: CachedVec::new(&minute10.first_height),
|
|
||||||
minute30_first_height: CachedVec::new(&minute30.first_height),
|
|
||||||
hour1_first_height: CachedVec::new(&hour1.first_height),
|
|
||||||
hour4_first_height: CachedVec::new(&hour4.first_height),
|
|
||||||
hour12_first_height: CachedVec::new(&hour12.first_height),
|
|
||||||
day1_first_height: CachedVec::new(&day1.first_height),
|
|
||||||
day3_first_height: CachedVec::new(&day3.first_height),
|
|
||||||
week1_first_height: CachedVec::new(&week1.first_height),
|
|
||||||
month1_first_height: CachedVec::new(&month1.first_height),
|
|
||||||
month3_first_height: CachedVec::new(&month3.first_height),
|
|
||||||
month6_first_height: CachedVec::new(&month6.first_height),
|
|
||||||
year1_first_height: CachedVec::new(&year1.first_height),
|
|
||||||
year10_first_height: CachedVec::new(&year10.first_height),
|
|
||||||
halving_identity: CachedVec::new(&halving.identity),
|
|
||||||
epoch_identity: CachedVec::new(&epoch.identity),
|
|
||||||
};
|
|
||||||
|
|
||||||
let timestamp = Timestamps::forced_import_from_locals(
|
let timestamp = Timestamps::forced_import_from_locals(
|
||||||
&db, version, &minute10, &minute30, &hour1, &hour4, &hour12, &day1, &day3, &week1,
|
&db, version, &minute10, &minute30, &hour1, &hour4, &hour12, &day1, &day3, &week1,
|
||||||
&month1, &month3, &month6, &year1, &year10,
|
&month1, &month3, &month6, &year1, &year10,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let this = Self {
|
let this = Self {
|
||||||
cached_mappings,
|
|
||||||
tx_heights: TxHeights::init(indexer),
|
tx_heights: TxHeights::init(indexer),
|
||||||
addr,
|
addr,
|
||||||
height,
|
height,
|
||||||
@@ -200,7 +166,7 @@ impl Vecs {
|
|||||||
let starting_day1 =
|
let starting_day1 =
|
||||||
self.compute_calendar_mappings(indexer, &starting_indexes, prev_height, exit)?;
|
self.compute_calendar_mappings(indexer, &starting_indexes, prev_height, exit)?;
|
||||||
|
|
||||||
self.compute_period_vecs(indexer, &starting_indexes, prev_height, starting_day1, exit)?;
|
self.compute_period_vecs(&starting_indexes, prev_height, starting_day1, exit)?;
|
||||||
|
|
||||||
self.timestamp.compute_per_resolution(
|
self.timestamp.compute_per_resolution(
|
||||||
indexer,
|
indexer,
|
||||||
@@ -380,23 +346,16 @@ impl Vecs {
|
|||||||
&indexer.vecs.blocks.weight,
|
&indexer.vecs.blocks.weight,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.epoch.first_height.compute_first_per_index(
|
self.epoch.first_height.inner.compute_first_per_index(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&self.height.epoch,
|
&self.height.epoch,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.epoch.identity.compute_from_index(
|
self.epoch.identity.inner.compute_from_index(
|
||||||
starting_difficulty,
|
starting_difficulty,
|
||||||
&self.epoch.first_height,
|
&self.epoch.first_height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.epoch.height_count.compute_count_from_indexes(
|
|
||||||
starting_difficulty,
|
|
||||||
&self.epoch.first_height,
|
|
||||||
&self.timestamp.monotonic,
|
|
||||||
exit,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let starting_halving = self
|
let starting_halving = self
|
||||||
.height
|
.height
|
||||||
.halving
|
.halving
|
||||||
@@ -408,12 +367,12 @@ impl Vecs {
|
|||||||
&indexer.vecs.blocks.weight,
|
&indexer.vecs.blocks.weight,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.halving.first_height.compute_first_per_index(
|
self.halving.first_height.inner.compute_first_per_index(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&self.height.halving,
|
&self.height.halving,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.halving.identity.compute_from_index(
|
self.halving.identity.inner.compute_from_index(
|
||||||
starting_halving,
|
starting_halving,
|
||||||
&self.halving.first_height,
|
&self.halving.first_height,
|
||||||
exit,
|
exit,
|
||||||
@@ -424,7 +383,6 @@ impl Vecs {
|
|||||||
|
|
||||||
fn compute_period_vecs(
|
fn compute_period_vecs(
|
||||||
&mut self,
|
&mut self,
|
||||||
indexer: &Indexer,
|
|
||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
prev_height: Height,
|
prev_height: Height,
|
||||||
starting_day1: Day1,
|
starting_day1: Day1,
|
||||||
@@ -432,7 +390,7 @@ impl Vecs {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
macro_rules! basic_period {
|
macro_rules! basic_period {
|
||||||
($period:ident) => {
|
($period:ident) => {
|
||||||
self.$period.first_height.compute_first_per_index(
|
self.$period.first_height.inner.compute_first_per_index(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&self.height.$period,
|
&self.height.$period,
|
||||||
exit,
|
exit,
|
||||||
@@ -455,7 +413,7 @@ impl Vecs {
|
|||||||
basic_period!(hour12);
|
basic_period!(hour12);
|
||||||
basic_period!(day3);
|
basic_period!(day3);
|
||||||
|
|
||||||
self.day1.first_height.compute_first_per_index(
|
self.day1.first_height.inner.compute_first_per_index(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&self.height.day1,
|
&self.height.day1,
|
||||||
exit,
|
exit,
|
||||||
@@ -469,18 +427,11 @@ impl Vecs {
|
|||||||
|(di, ..)| (di, Date::from(di)),
|
|(di, ..)| (di, Date::from(di)),
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
self.day1.height_count.compute_count_from_indexes(
|
|
||||||
starting_day1,
|
|
||||||
&self.day1.first_height,
|
|
||||||
&indexer.vecs.blocks.weight,
|
|
||||||
exit,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let ts = &self.timestamp.monotonic;
|
let ts = &self.timestamp.monotonic;
|
||||||
|
|
||||||
macro_rules! dated_period {
|
macro_rules! dated_period {
|
||||||
($period:ident) => {{
|
($period:ident) => {{
|
||||||
self.$period.first_height.compute_first_per_index(
|
self.$period.first_height.inner.compute_first_per_index(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&self.height.$period,
|
&self.height.$period,
|
||||||
exit,
|
exit,
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Date, Height, Month1, 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<Month1, Month1>>>,
|
|
||||||
pub date: M::Stored<EagerVec<PcoVec<Month1, Date>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Month1, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "month1_index", version)?,
|
|
||||||
date: EagerVec::forced_import(db, "date", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Date, Height, Month3, 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<Month3, Month3>>>,
|
|
||||||
pub date: M::Stored<EagerVec<PcoVec<Month3, Date>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Month3, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "month3_index", version)?,
|
|
||||||
date: EagerVec::forced_import(db, "date", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Date, Height, Month6, 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<Month6, Month6>>>,
|
|
||||||
pub date: M::Stored<EagerVec<PcoVec<Month6, Date>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Month6, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "month6_index", version)?,
|
|
||||||
date: EagerVec::forced_import(db, "date", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
68
crates/brk_computer/src/indexes/resolution.rs
Normal file
68
crates/brk_computer/src/indexes/resolution.rs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
use brk_error::Result;
|
||||||
|
use brk_traversable::Traversable;
|
||||||
|
use brk_types::{Date, Height, Version};
|
||||||
|
use vecdb::{
|
||||||
|
CachedVec, Database, EagerVec, ImportableVec, PcoVec, PcoVecValue, Rw, StorageMode, VecIndex,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Resolution with identity mapping and cached first-height lookup.
|
||||||
|
#[derive(Traversable)]
|
||||||
|
pub struct ResolutionVecs<I: VecIndex + PcoVecValue, M: StorageMode = Rw> {
|
||||||
|
pub identity: M::Stored<EagerVec<PcoVec<I, I>>>,
|
||||||
|
pub first_height: CachedVec<M::Stored<EagerVec<PcoVec<I, Height>>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resolution with both identity and first-height cached (halving, epoch).
|
||||||
|
#[derive(Traversable)]
|
||||||
|
pub struct CachedResolutionVecs<I: VecIndex + PcoVecValue, M: StorageMode = Rw> {
|
||||||
|
pub identity: CachedVec<M::Stored<EagerVec<PcoVec<I, I>>>>,
|
||||||
|
pub first_height: CachedVec<M::Stored<EagerVec<PcoVec<I, Height>>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<I: VecIndex + PcoVecValue> CachedResolutionVecs<I> {
|
||||||
|
pub(crate) fn forced_import(
|
||||||
|
db: &Database,
|
||||||
|
identity_name: &str,
|
||||||
|
version: Version,
|
||||||
|
) -> Result<Self> {
|
||||||
|
Ok(Self {
|
||||||
|
identity: CachedVec::wrap(EagerVec::forced_import(db, identity_name, version)?),
|
||||||
|
first_height: CachedVec::wrap(EagerVec::forced_import(db, "first_height", version)?),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<I: VecIndex + PcoVecValue> ResolutionVecs<I> {
|
||||||
|
pub(crate) fn forced_import(
|
||||||
|
db: &Database,
|
||||||
|
identity_name: &str,
|
||||||
|
version: Version,
|
||||||
|
) -> Result<Self> {
|
||||||
|
Ok(Self {
|
||||||
|
identity: EagerVec::forced_import(db, identity_name, version)?,
|
||||||
|
first_height: CachedVec::wrap(EagerVec::forced_import(db, "first_height", version)?),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resolution with identity, date, and cached first-height lookup.
|
||||||
|
#[derive(Traversable)]
|
||||||
|
pub struct DatedResolutionVecs<I: VecIndex + PcoVecValue, M: StorageMode = Rw> {
|
||||||
|
pub identity: M::Stored<EagerVec<PcoVec<I, I>>>,
|
||||||
|
pub date: M::Stored<EagerVec<PcoVec<I, Date>>>,
|
||||||
|
pub first_height: CachedVec<M::Stored<EagerVec<PcoVec<I, Height>>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<I: VecIndex + PcoVecValue> DatedResolutionVecs<I> {
|
||||||
|
pub(crate) fn forced_import(
|
||||||
|
db: &Database,
|
||||||
|
identity_name: &str,
|
||||||
|
version: Version,
|
||||||
|
) -> Result<Self> {
|
||||||
|
Ok(Self {
|
||||||
|
identity: EagerVec::forced_import(db, identity_name, version)?,
|
||||||
|
date: EagerVec::forced_import(db, "date", version)?,
|
||||||
|
first_height: CachedVec::wrap(EagerVec::forced_import(db, "first_height", version)?),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,8 @@ use brk_types::{
|
|||||||
};
|
};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use vecdb::{
|
use vecdb::{
|
||||||
Database, EagerVec, Exit, ImportableVec, LazyVecFrom1, PcoVec, ReadableCloneableVec,
|
Database, EagerVec, Exit, ImportableVec, LazyVecFrom1, PcoVec, ReadableVec, Rw, StorageMode,
|
||||||
ReadableVec, Rw, StorageMode, Version,
|
Version,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::internal::PerResolution;
|
use crate::internal::PerResolution;
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Date, Height, Version, Week1};
|
|
||||||
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<Week1, Week1>>>,
|
|
||||||
pub date: M::Stored<EagerVec<PcoVec<Week1, Date>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Week1, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "week1_index", version)?,
|
|
||||||
date: EagerVec::forced_import(db, "date", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Date, Height, Version, Year1};
|
|
||||||
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<Year1, Year1>>>,
|
|
||||||
pub date: M::Stored<EagerVec<PcoVec<Year1, Date>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Year1, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "year1_index", version)?,
|
|
||||||
date: EagerVec::forced_import(db, "date", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::{Date, Height, Version, Year10};
|
|
||||||
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<Year10, Year10>>>,
|
|
||||||
pub date: M::Stored<EagerVec<PcoVec<Year10, Date>>>,
|
|
||||||
pub first_height: M::Stored<EagerVec<PcoVec<Year10, Height>>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Vecs {
|
|
||||||
pub(crate) fn forced_import(db: &Database, version: Version) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
identity: EagerVec::forced_import(db, "year10_index", version)?,
|
|
||||||
date: EagerVec::forced_import(db, "date", version)?,
|
|
||||||
first_height: EagerVec::forced_import(db, "first_height", version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -123,7 +123,7 @@ impl RealizedEnvelope {
|
|||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let spot = &prices.cached_spot_cents;
|
let spot = &prices.spot.cents.height;
|
||||||
|
|
||||||
// Zone: spot vs own envelope bands (-4 to +4)
|
// Zone: spot vs own envelope bands (-4 to +4)
|
||||||
self.compute_index(spot, starting_indexes, exit)?;
|
self.compute_index(spot, starting_indexes, exit)?;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
|||||||
use super::Vecs;
|
use super::Vecs;
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, PerBlockAggregated},
|
internal::{PerBlockAggregated, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -13,7 +13,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self(PerBlockAggregated::forced_import(
|
Ok(Self(PerBlockAggregated::forced_import(
|
||||||
db,
|
db,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use brk_types::Version;
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts,
|
WindowStartVec, Windows,
|
||||||
db_utils::{finalize_db, open_db},
|
db_utils::{finalize_db, open_db},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -18,7 +18,7 @@ impl Vecs {
|
|||||||
parent_path: &Path,
|
parent_path: &Path,
|
||||||
parent_version: Version,
|
parent_version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let db = open_db(parent_path, super::DB_NAME, 20_000_000)?;
|
let db = open_db(parent_path, super::DB_NAME, 20_000_000)?;
|
||||||
let version = parent_version;
|
let version = parent_version;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::sync::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use vecdb::{CachedVec, CachedVecBudget, ReadableBoxedVec, VecIndex, VecValue};
|
use vecdb::{CachedVec, CachedVecBudget, ReadableVec, TypedVec};
|
||||||
|
|
||||||
const MAX_CACHED: usize = 256;
|
const MAX_CACHED: usize = 256;
|
||||||
const MIN_ACCESSES: u64 = 2;
|
const MIN_ACCESSES: u64 = 2;
|
||||||
@@ -67,10 +67,13 @@ fn evict_less_popular_than(threshold: u64) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps a boxed source in a budgeted [`CachedVec`] and registers it for eviction.
|
/// Wraps a source vec in a budgeted [`CachedVec`] and registers it for eviction.
|
||||||
pub fn cache_wrap<I: VecIndex, T: VecValue>(source: ReadableBoxedVec<I, T>) -> CachedVec<I, T> {
|
pub fn cache_wrap<V>(source: V) -> CachedVec<V>
|
||||||
|
where
|
||||||
|
V: TypedVec + ReadableVec<V::I, V::T> + Clone + 'static,
|
||||||
|
{
|
||||||
let access_count = Arc::new(AtomicU64::new(0));
|
let access_count = Arc::new(AtomicU64::new(0));
|
||||||
let cached = CachedVec::new_budgeted(source, &BUDGET, access_count.clone());
|
let cached = CachedVec::wrap_budgeted(source, &BUDGET, access_count.clone());
|
||||||
let clone = cached.clone();
|
let clone = cached.clone();
|
||||||
CACHES.lock().push(CacheEntry {
|
CACHES.lock().push(CacheEntry {
|
||||||
access_count,
|
access_count,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use brk_traversable::Traversable;
|
use brk_traversable::Traversable;
|
||||||
|
|
||||||
#[derive(Clone, Traversable)]
|
#[derive(Clone, Copy, Traversable)]
|
||||||
pub struct Windows<A> {
|
pub struct Windows<A> {
|
||||||
pub _24h: A,
|
pub _24h: A,
|
||||||
pub _1w: A,
|
pub _1w: A,
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ impl AmountPerBlock {
|
|||||||
self.cents.compute_binary::<Sats, Cents, SatsToCents>(
|
self.cents.compute_binary::<Sats, Cents, SatsToCents>(
|
||||||
max_from,
|
max_from,
|
||||||
&self.sats.height,
|
&self.sats.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ impl AmountBlock {
|
|||||||
self.cents.compute_binary::<Sats, Cents, SatsToCents>(
|
self.cents.compute_binary::<Sats, Cents, SatsToCents>(
|
||||||
max_from,
|
max_from,
|
||||||
&self.sats,
|
&self.sats,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
AmountPerBlockCumulative, CachedWindowStarts, LazyRollingAvgsAmountFromHeight,
|
AmountPerBlockCumulative, LazyRollingAvgsAmountFromHeight, LazyRollingSumsAmountFromHeight,
|
||||||
LazyRollingSumsAmountFromHeight,
|
WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
prices,
|
prices,
|
||||||
};
|
};
|
||||||
@@ -31,7 +31,7 @@ impl AmountPerBlockCumulativeRolling {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let v = version + VERSION;
|
let v = version + VERSION;
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
AmountPerBlockCumulativeRolling, CachedWindowStarts, RollingDistributionAmountPerBlock,
|
AmountPerBlockCumulativeRolling, RollingDistributionAmountPerBlock, WindowStartVec,
|
||||||
WindowStarts,
|
WindowStarts, Windows,
|
||||||
},
|
},
|
||||||
prices,
|
prices,
|
||||||
};
|
};
|
||||||
@@ -31,7 +31,7 @@ impl AmountPerBlockFull {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let v = version + VERSION;
|
let v = version + VERSION;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use brk_traversable::Traversable;
|
use brk_traversable::Traversable;
|
||||||
use brk_types::{Bitcoin, Cents, Dollars, Height, Sats, StoredF32, Version};
|
use brk_types::{Bitcoin, Cents, Dollars, Height, Sats, StoredF32, Version};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use vecdb::{DeltaAvg, LazyDeltaVec, LazyVecFrom1, ReadableCloneableVec};
|
use vecdb::{DeltaAvg, LazyDeltaVec, LazyVecFrom1, ReadOnlyClone, ReadableCloneableVec};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
AvgCentsToUsd, AvgSatsToBtc, CachedWindowStarts, DerivedResolutions, LazyPerBlock,
|
AvgCentsToUsd, AvgSatsToBtc, DerivedResolutions, LazyPerBlock, LazyRollingAvgFromHeight,
|
||||||
LazyRollingAvgFromHeight, Resolutions, Windows,
|
Resolutions, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,15 +31,15 @@ impl LazyRollingAvgsAmountFromHeight {
|
|||||||
version: Version,
|
version: Version,
|
||||||
cumulative_sats: &(impl ReadableCloneableVec<Height, Sats> + 'static),
|
cumulative_sats: &(impl ReadableCloneableVec<Height, Sats> + 'static),
|
||||||
cumulative_cents: &(impl ReadableCloneableVec<Height, Cents> + 'static),
|
cumulative_cents: &(impl ReadableCloneableVec<Height, Cents> + 'static),
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let cum_sats = cumulative_sats.read_only_boxed_clone();
|
let cum_sats = cumulative_sats.read_only_boxed_clone();
|
||||||
let cum_cents = cumulative_cents.read_only_boxed_clone();
|
let cum_cents = cumulative_cents.read_only_boxed_clone();
|
||||||
|
|
||||||
let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec<Height, Height>| {
|
let make_slot = |suffix: &str, cached_start: &&WindowStartVec| {
|
||||||
let full_name = format!("{name}_{suffix}");
|
let full_name = format!("{name}_{suffix}");
|
||||||
let cached = cached_start.clone();
|
let cached = cached_start.read_only_clone();
|
||||||
let starts_version = cached.version();
|
let starts_version = cached.version();
|
||||||
|
|
||||||
// Sats lazy rolling avg → f64
|
// Sats lazy rolling avg → f64
|
||||||
@@ -50,12 +50,12 @@ impl LazyRollingAvgsAmountFromHeight {
|
|||||||
starts_version,
|
starts_version,
|
||||||
{
|
{
|
||||||
let cached = cached.clone();
|
let cached = cached.clone();
|
||||||
move || cached.get()
|
move || cached.cached()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let sats_resolutions = Resolutions::forced_import(
|
let sats_resolutions = Resolutions::forced_import(
|
||||||
&format!("{full_name}_sats"),
|
&format!("{full_name}_sats"),
|
||||||
sats_avg.read_only_boxed_clone(),
|
sats_avg.clone(),
|
||||||
version,
|
version,
|
||||||
indexes,
|
indexes,
|
||||||
);
|
);
|
||||||
@@ -84,11 +84,11 @@ impl LazyRollingAvgsAmountFromHeight {
|
|||||||
version,
|
version,
|
||||||
cum_cents.clone(),
|
cum_cents.clone(),
|
||||||
starts_version,
|
starts_version,
|
||||||
move || cached.get(),
|
move || cached.cached(),
|
||||||
);
|
);
|
||||||
let cents_resolutions = Resolutions::forced_import(
|
let cents_resolutions = Resolutions::forced_import(
|
||||||
&format!("{full_name}_cents"),
|
&format!("{full_name}_cents"),
|
||||||
cents_avg.read_only_boxed_clone(),
|
cents_avg.clone(),
|
||||||
version,
|
version,
|
||||||
indexes,
|
indexes,
|
||||||
);
|
);
|
||||||
@@ -119,6 +119,6 @@ impl LazyRollingAvgsAmountFromHeight {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Self(cached_starts.0.map_with_suffix(make_slot))
|
Self(cached_starts.map_with_suffix(make_slot))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use brk_traversable::Traversable;
|
use brk_traversable::Traversable;
|
||||||
use brk_types::{Bitcoin, Cents, Dollars, Height, Sats, Version};
|
use brk_types::{Bitcoin, Cents, Dollars, Height, Sats, Version};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use vecdb::{DeltaSub, LazyDeltaVec, LazyVecFrom1, ReadableCloneableVec};
|
use vecdb::{DeltaSub, LazyDeltaVec, LazyVecFrom1, ReadOnlyClone, ReadableCloneableVec};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, CentsUnsignedToDollars, DerivedResolutions, LazyPerBlock,
|
CentsUnsignedToDollars, DerivedResolutions, LazyPerBlock, LazyRollingSumFromHeight,
|
||||||
LazyRollingSumFromHeight, Resolutions, SatsToBitcoin, Windows,
|
Resolutions, SatsToBitcoin, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,15 +31,15 @@ impl LazyRollingSumsAmountFromHeight {
|
|||||||
version: Version,
|
version: Version,
|
||||||
cumulative_sats: &(impl ReadableCloneableVec<Height, Sats> + 'static),
|
cumulative_sats: &(impl ReadableCloneableVec<Height, Sats> + 'static),
|
||||||
cumulative_cents: &(impl ReadableCloneableVec<Height, Cents> + 'static),
|
cumulative_cents: &(impl ReadableCloneableVec<Height, Cents> + 'static),
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let cum_sats = cumulative_sats.read_only_boxed_clone();
|
let cum_sats = cumulative_sats.read_only_boxed_clone();
|
||||||
let cum_cents = cumulative_cents.read_only_boxed_clone();
|
let cum_cents = cumulative_cents.read_only_boxed_clone();
|
||||||
|
|
||||||
let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec<Height, Height>| {
|
let make_slot = |suffix: &str, cached_start: &&WindowStartVec| {
|
||||||
let full_name = format!("{name}_{suffix}");
|
let full_name = format!("{name}_{suffix}");
|
||||||
let cached = cached_start.clone();
|
let cached = cached_start.read_only_clone();
|
||||||
let starts_version = cached.version();
|
let starts_version = cached.version();
|
||||||
|
|
||||||
// Sats lazy rolling sum
|
// Sats lazy rolling sum
|
||||||
@@ -50,12 +50,12 @@ impl LazyRollingSumsAmountFromHeight {
|
|||||||
starts_version,
|
starts_version,
|
||||||
{
|
{
|
||||||
let cached = cached.clone();
|
let cached = cached.clone();
|
||||||
move || cached.get()
|
move || cached.cached()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let sats_resolutions = Resolutions::forced_import(
|
let sats_resolutions = Resolutions::forced_import(
|
||||||
&format!("{full_name}_sats"),
|
&format!("{full_name}_sats"),
|
||||||
sats_sum.read_only_boxed_clone(),
|
sats_sum.clone(),
|
||||||
version,
|
version,
|
||||||
indexes,
|
indexes,
|
||||||
);
|
);
|
||||||
@@ -84,11 +84,11 @@ impl LazyRollingSumsAmountFromHeight {
|
|||||||
version,
|
version,
|
||||||
cum_cents.clone(),
|
cum_cents.clone(),
|
||||||
starts_version,
|
starts_version,
|
||||||
move || cached.get(),
|
move || cached.cached(),
|
||||||
);
|
);
|
||||||
let cents_resolutions = Resolutions::forced_import(
|
let cents_resolutions = Resolutions::forced_import(
|
||||||
&format!("{full_name}_cents"),
|
&format!("{full_name}_cents"),
|
||||||
cents_sum.read_only_boxed_clone(),
|
cents_sum.clone(),
|
||||||
version,
|
version,
|
||||||
indexes,
|
indexes,
|
||||||
);
|
);
|
||||||
@@ -119,6 +119,6 @@ impl LazyRollingSumsAmountFromHeight {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Self(cached_starts.0.map_with_suffix(make_slot))
|
Self(cached_starts.map_with_suffix(make_slot))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use vecdb::{Database, Rw, StorageMode};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{AmountPerBlock, CachedWindowStarts, LazyRollingDeltasFromHeight},
|
internal::{AmountPerBlock, LazyRollingDeltasFromHeight, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Deref, DerefMut, Traversable)]
|
#[derive(Deref, DerefMut, Traversable)]
|
||||||
@@ -24,7 +24,7 @@ impl AmountPerBlockWithDeltas {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let inner = AmountPerBlock::forced_import(db, name, version, indexes)?;
|
let inner = AmountPerBlock::forced_import(db, name, version, indexes)?;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use vecdb::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, NumericValue, PerBlock, RollingComplete, WindowStarts},
|
internal::{NumericValue, PerBlock, RollingComplete, WindowStartVec, WindowStarts, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Traversable)]
|
#[derive(Traversable)]
|
||||||
@@ -31,7 +31,7 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let sum = EagerVec::forced_import(db, &format!("{name}_sum"), version)?;
|
let sum = EagerVec::forced_import(db, &format!("{name}_sum"), version)?;
|
||||||
let cumulative =
|
let cumulative =
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use brk_types::{Height, Version};
|
|||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use vecdb::{
|
use vecdb::{
|
||||||
BinaryTransform, Database, EagerVec, Exit, ImportableVec, PcoVec, ReadableCloneableVec,
|
BinaryTransform, Database, EagerVec, Exit, ImportableVec, PcoVec, ReadOnlyClone, ReadableVec,
|
||||||
ReadableVec, Rw, StorageMode, VecValue,
|
Rw, StorageMode, VecValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::indexes;
|
use crate::indexes;
|
||||||
@@ -39,7 +39,7 @@ where
|
|||||||
let height: EagerVec<PcoVec<Height, T>> = EagerVec::forced_import(db, name, version)?;
|
let height: EagerVec<PcoVec<Height, T>> = EagerVec::forced_import(db, name, version)?;
|
||||||
|
|
||||||
let resolutions =
|
let resolutions =
|
||||||
Resolutions::forced_import(name, height.read_only_boxed_clone(), version, indexes);
|
Resolutions::forced_import(name, height.read_only_clone(), version, indexes);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
height,
|
height,
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
use brk_error::Result;
|
||||||
|
use brk_traversable::Traversable;
|
||||||
|
use brk_types::{Height, Version};
|
||||||
|
use derive_more::{Deref, DerefMut};
|
||||||
|
use schemars::JsonSchema;
|
||||||
|
use vecdb::{CachedVec, Database, EagerVec, ImportableVec, PcoVec, ReadOnlyClone, Rw, StorageMode};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
indexes,
|
||||||
|
internal::{NumericValue, Resolutions},
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Like [`PerBlock`](super::PerBlock) but with height wrapped in [`CachedVec`]
|
||||||
|
/// for fast repeated reads.
|
||||||
|
#[derive(Deref, DerefMut, Traversable)]
|
||||||
|
#[traversable(merge)]
|
||||||
|
pub struct CachedPerBlock<T, M: StorageMode = Rw>
|
||||||
|
where
|
||||||
|
T: NumericValue + JsonSchema,
|
||||||
|
{
|
||||||
|
pub height: CachedVec<M::Stored<EagerVec<PcoVec<Height, T>>>>,
|
||||||
|
#[deref]
|
||||||
|
#[deref_mut]
|
||||||
|
#[traversable(flatten)]
|
||||||
|
pub resolutions: Box<Resolutions<T>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> CachedPerBlock<T>
|
||||||
|
where
|
||||||
|
T: NumericValue + JsonSchema,
|
||||||
|
{
|
||||||
|
pub(crate) fn forced_import(
|
||||||
|
db: &Database,
|
||||||
|
name: &str,
|
||||||
|
version: Version,
|
||||||
|
indexes: &indexes::Vecs,
|
||||||
|
) -> Result<Self> {
|
||||||
|
let height: EagerVec<PcoVec<Height, T>> = EagerVec::forced_import(db, name, version)?;
|
||||||
|
|
||||||
|
let resolutions =
|
||||||
|
Resolutions::forced_import(name, height.read_only_clone(), version, indexes);
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
height: CachedVec::wrap(height),
|
||||||
|
resolutions: Box::new(resolutions),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,8 +18,8 @@ use vecdb::{Database, EagerVec, Exit, ImportableVec, PcoVec, Rw, StorageMode};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, LazyRollingAvgsFromHeight, LazyRollingSumsFromHeight, NumericValue,
|
LazyRollingAvgsFromHeight, LazyRollingSumsFromHeight, NumericValue, PerBlock,
|
||||||
PerBlock,
|
WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let block = EagerVec::forced_import(db, name, version)?;
|
let block = EagerVec::forced_import(db, name, version)?;
|
||||||
let cumulative =
|
let cumulative =
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use vecdb::{Database, EagerVec, Exit, ImportableVec, PcoVec, Rw, StorageMode};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, NumericValue, PerBlock, RollingComplete, WindowStarts},
|
internal::{NumericValue, PerBlock, RollingComplete, WindowStartVec, WindowStarts, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Traversable)]
|
#[derive(Traversable)]
|
||||||
@@ -33,7 +33,7 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let block = EagerVec::forced_import(db, name, version)?;
|
let block = EagerVec::forced_import(db, name, version)?;
|
||||||
let cumulative =
|
let cumulative =
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ use vecdb::{ReadableCloneableVec, UnaryTransform};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, ComputedVecValue, LazyPerBlock, LazyRollingComplete, NumericValue,
|
ComputedVecValue, LazyPerBlock, LazyRollingComplete, NumericValue, PerBlockFull,
|
||||||
PerBlockFull,
|
WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
source: &PerBlockFull<S1T>,
|
source: &PerBlockFull<S1T>,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let cumulative = LazyPerBlock::from_computed::<F>(
|
let cumulative = LazyPerBlock::from_computed::<F>(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
mod aggregated;
|
mod aggregated;
|
||||||
mod base;
|
mod base;
|
||||||
|
mod cached;
|
||||||
mod cumulative_rolling;
|
mod cumulative_rolling;
|
||||||
mod distribution;
|
mod distribution;
|
||||||
mod full;
|
mod full;
|
||||||
@@ -12,6 +13,7 @@ mod with_deltas;
|
|||||||
|
|
||||||
pub use aggregated::*;
|
pub use aggregated::*;
|
||||||
pub use base::*;
|
pub use base::*;
|
||||||
|
pub use cached::*;
|
||||||
pub use cumulative_rolling::*;
|
pub use cumulative_rolling::*;
|
||||||
pub use distribution::*;
|
pub use distribution::*;
|
||||||
pub use full::*;
|
pub use full::*;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ use brk_types::{
|
|||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use vecdb::{
|
use vecdb::{
|
||||||
AggFold, LazyAggVec, ReadOnlyClone, ReadableBoxedVec, ReadableCloneableVec, ReadableVec,
|
AggFold, LazyAggVec, ReadOnlyClone, ReadableCloneableVec, ReadableVec, TypedVec, VecIndex,
|
||||||
VecIndex, VecValue,
|
VecValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -102,47 +102,48 @@ impl<T> Resolutions<T>
|
|||||||
where
|
where
|
||||||
T: NumericValue + JsonSchema,
|
T: NumericValue + JsonSchema,
|
||||||
{
|
{
|
||||||
pub(crate) fn forced_import(
|
pub(crate) fn forced_import<V>(
|
||||||
name: &str,
|
name: &str,
|
||||||
height_source: ReadableBoxedVec<Height, T>,
|
height_source: V,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self
|
||||||
|
where
|
||||||
|
V: TypedVec<I = Height, T = T> + ReadableVec<Height, T> + Clone + 'static,
|
||||||
|
{
|
||||||
let cached = cache_wrap(height_source);
|
let cached = cache_wrap(height_source);
|
||||||
let height_source = cached.read_only_boxed_clone();
|
let height_source = cached.read_only_boxed_clone();
|
||||||
|
|
||||||
let cm = &indexes.cached_mappings;
|
|
||||||
|
|
||||||
macro_rules! res {
|
macro_rules! res {
|
||||||
($cached:expr) => {{
|
($field:expr) => {{
|
||||||
let cached = $cached.clone();
|
let cached = $field.read_only_clone();
|
||||||
let mapping_version = cached.version();
|
let mapping_version = cached.version();
|
||||||
LazyAggVec::new(
|
LazyAggVec::new(
|
||||||
name,
|
name,
|
||||||
version,
|
version,
|
||||||
mapping_version,
|
mapping_version,
|
||||||
height_source.clone(),
|
height_source.clone(),
|
||||||
move || cached.get(),
|
move || cached.cached(),
|
||||||
)
|
)
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
Self(PerResolution {
|
Self(PerResolution {
|
||||||
minute10: res!(cm.minute10_first_height),
|
minute10: res!(indexes.minute10.first_height),
|
||||||
minute30: res!(cm.minute30_first_height),
|
minute30: res!(indexes.minute30.first_height),
|
||||||
hour1: res!(cm.hour1_first_height),
|
hour1: res!(indexes.hour1.first_height),
|
||||||
hour4: res!(cm.hour4_first_height),
|
hour4: res!(indexes.hour4.first_height),
|
||||||
hour12: res!(cm.hour12_first_height),
|
hour12: res!(indexes.hour12.first_height),
|
||||||
day1: res!(cm.day1_first_height),
|
day1: res!(indexes.day1.first_height),
|
||||||
day3: res!(cm.day3_first_height),
|
day3: res!(indexes.day3.first_height),
|
||||||
week1: res!(cm.week1_first_height),
|
week1: res!(indexes.week1.first_height),
|
||||||
month1: res!(cm.month1_first_height),
|
month1: res!(indexes.month1.first_height),
|
||||||
month3: res!(cm.month3_first_height),
|
month3: res!(indexes.month3.first_height),
|
||||||
month6: res!(cm.month6_first_height),
|
month6: res!(indexes.month6.first_height),
|
||||||
year1: res!(cm.year1_first_height),
|
year1: res!(indexes.year1.first_height),
|
||||||
year10: res!(cm.year10_first_height),
|
year10: res!(indexes.year10.first_height),
|
||||||
halving: res!(cm.halving_identity),
|
halving: res!(indexes.halving.identity),
|
||||||
epoch: res!(cm.epoch_identity),
|
epoch: res!(indexes.epoch.identity),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, NumericValue, PerBlock, RollingComplete, WindowStarts},
|
internal::{NumericValue, PerBlock, RollingComplete, WindowStartVec, WindowStarts, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Traversable)]
|
#[derive(Traversable)]
|
||||||
@@ -33,7 +33,7 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let cumulative =
|
let cumulative =
|
||||||
PerBlock::forced_import(db, &format!("{name}_cumulative"), version, indexes)?;
|
PerBlock::forced_import(db, &format!("{name}_cumulative"), version, indexes)?;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use vecdb::{Database, EagerVec, Exit, ImportableVec, PcoVec, Rw, StorageMode};
|
|||||||
|
|
||||||
use crate::indexes;
|
use crate::indexes;
|
||||||
|
|
||||||
use crate::internal::{CachedWindowStarts, LazyRollingAvgsFromHeight, NumericValue};
|
use crate::internal::{LazyRollingAvgsFromHeight, NumericValue, WindowStartVec, Windows};
|
||||||
|
|
||||||
#[derive(Traversable)]
|
#[derive(Traversable)]
|
||||||
pub struct PerBlockRollingAverage<T, M: StorageMode = Rw>
|
pub struct PerBlockRollingAverage<T, M: StorageMode = Rw>
|
||||||
@@ -35,7 +35,7 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let block: EagerVec<PcoVec<Height, T>> = EagerVec::forced_import(db, name, version)?;
|
let block: EagerVec<PcoVec<Height, T>> = EagerVec::forced_import(db, name, version)?;
|
||||||
let cumulative: EagerVec<PcoVec<Height, T>> =
|
let cumulative: EagerVec<PcoVec<Height, T>> =
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ use vecdb::{Rw, StorageMode};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{BpsType, CachedWindowStarts, LazyRollingDeltasFromHeight, NumericValue, PerBlock},
|
internal::{
|
||||||
|
BpsType, LazyRollingDeltasFromHeight, NumericValue, PerBlock, WindowStartVec, Windows,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Deref, DerefMut, Traversable)]
|
#[derive(Deref, DerefMut, Traversable)]
|
||||||
@@ -35,7 +37,7 @@ where
|
|||||||
version: Version,
|
version: Version,
|
||||||
delta_version_offset: Version,
|
delta_version_offset: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let base = PerBlock::forced_import(db, name, version, indexes)?;
|
let base = PerBlock::forced_import(db, name, version, indexes)?;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use vecdb::{Database, Exit, Rw, StorageMode};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, CentsType, FiatBlock, FiatPerBlock, LazyRollingSumsFiatFromHeight,
|
CentsType, FiatBlock, FiatPerBlock, LazyRollingSumsFiatFromHeight, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ impl<C: CentsType> FiatPerBlockCumulativeWithSums<C> {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let block = FiatBlock::forced_import(db, name, version)?;
|
let block = FiatBlock::forced_import(db, name, version)?;
|
||||||
let cumulative =
|
let cumulative =
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use vecdb::{Database, Rw, StorageMode};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{BpsType, CachedWindowStarts, LazyRollingDeltasFiatFromHeight},
|
internal::{BpsType, LazyRollingDeltasFiatFromHeight, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{CentsType, FiatPerBlockCumulativeWithSums};
|
use super::{CentsType, FiatPerBlockCumulativeWithSums};
|
||||||
@@ -37,7 +37,7 @@ where
|
|||||||
version: Version,
|
version: Version,
|
||||||
delta_version_offset: Version,
|
delta_version_offset: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let inner = FiatPerBlockCumulativeWithSums::forced_import(
|
let inner = FiatPerBlockCumulativeWithSums::forced_import(
|
||||||
db,
|
db,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use brk_traversable::Traversable;
|
use brk_traversable::Traversable;
|
||||||
use brk_types::{Dollars, Height, Version};
|
use brk_types::{Dollars, Height, Version};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use vecdb::{DeltaSub, LazyDeltaVec, LazyVecFrom1, ReadableCloneableVec};
|
use vecdb::{DeltaSub, LazyDeltaVec, LazyVecFrom1, ReadOnlyClone, ReadableCloneableVec};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, CentsType, DerivedResolutions, LazyPerBlock, LazyRollingSumFromHeight,
|
CentsType, DerivedResolutions, LazyPerBlock, LazyRollingSumFromHeight, Resolutions,
|
||||||
Resolutions, Windows,
|
WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,14 +28,14 @@ impl<C: CentsType> LazyRollingSumsFiatFromHeight<C> {
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
cumulative_cents: &(impl ReadableCloneableVec<Height, C> + 'static),
|
cumulative_cents: &(impl ReadableCloneableVec<Height, C> + 'static),
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let cum_cents = cumulative_cents.read_only_boxed_clone();
|
let cum_cents = cumulative_cents.read_only_boxed_clone();
|
||||||
|
|
||||||
let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec<Height, Height>| {
|
let make_slot = |suffix: &str, cached_start: &&WindowStartVec| {
|
||||||
let full_name = format!("{name}_{suffix}");
|
let full_name = format!("{name}_{suffix}");
|
||||||
let cached = cached_start.clone();
|
let cached = cached_start.read_only_clone();
|
||||||
let starts_version = cached.version();
|
let starts_version = cached.version();
|
||||||
|
|
||||||
let cents_sum = LazyDeltaVec::<Height, C, C, DeltaSub>::new(
|
let cents_sum = LazyDeltaVec::<Height, C, C, DeltaSub>::new(
|
||||||
@@ -43,11 +43,11 @@ impl<C: CentsType> LazyRollingSumsFiatFromHeight<C> {
|
|||||||
version,
|
version,
|
||||||
cum_cents.clone(),
|
cum_cents.clone(),
|
||||||
starts_version,
|
starts_version,
|
||||||
move || cached.get(),
|
move || cached.cached(),
|
||||||
);
|
);
|
||||||
let cents_resolutions = Resolutions::forced_import(
|
let cents_resolutions = Resolutions::forced_import(
|
||||||
&format!("{full_name}_cents"),
|
&format!("{full_name}_cents"),
|
||||||
cents_sum.read_only_boxed_clone(),
|
cents_sum.clone(),
|
||||||
version,
|
version,
|
||||||
indexes,
|
indexes,
|
||||||
);
|
);
|
||||||
@@ -72,6 +72,6 @@ impl<C: CentsType> LazyRollingSumsFiatFromHeight<C> {
|
|||||||
LazyRollingSumFiatFromHeight { usd, cents }
|
LazyRollingSumFiatFromHeight { usd, cents }
|
||||||
};
|
};
|
||||||
|
|
||||||
Self(cached_starts.0.map_with_suffix(make_slot))
|
Self(cached_starts.map_with_suffix(make_slot))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use vecdb::{Database, Rw, StorageMode};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{BpsType, CachedWindowStarts, LazyRollingDeltasFiatFromHeight},
|
internal::{BpsType, LazyRollingDeltasFiatFromHeight, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{CentsType, FiatPerBlock};
|
use super::{CentsType, FiatPerBlock};
|
||||||
@@ -38,7 +38,7 @@ where
|
|||||||
version: Version,
|
version: Version,
|
||||||
delta_version_offset: Version,
|
delta_version_offset: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let inner = FiatPerBlock::forced_import(db, name, version, indexes)?;
|
let inner = FiatPerBlock::forced_import(db, name, version, indexes)?;
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,16 @@ use brk_traversable::Traversable;
|
|||||||
use brk_types::{Height, Version};
|
use brk_types::{Height, Version};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use vecdb::{LazyVecFrom1, ReadOnlyClone, ReadableBoxedVec, ReadableCloneableVec, UnaryTransform};
|
use vecdb::{
|
||||||
|
LazyVecFrom1, ReadOnlyClone, ReadableBoxedVec, ReadableCloneableVec, ReadableVec, TypedVec,
|
||||||
|
UnaryTransform,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{ComputedVecValue, DerivedResolutions, NumericValue, PerBlock},
|
internal::{
|
||||||
|
CachedPerBlock, ComputedVecValue, DerivedResolutions, NumericValue, PerBlock, Resolutions,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
#[derive(Clone, Deref, DerefMut, Traversable)]
|
#[derive(Clone, Deref, DerefMut, Traversable)]
|
||||||
#[traversable(merge)]
|
#[traversable(merge)]
|
||||||
@@ -27,6 +32,23 @@ where
|
|||||||
T: ComputedVecValue + JsonSchema + 'static,
|
T: ComputedVecValue + JsonSchema + 'static,
|
||||||
S1T: ComputedVecValue + JsonSchema,
|
S1T: ComputedVecValue + JsonSchema,
|
||||||
{
|
{
|
||||||
|
pub(crate) fn from_resolutions<F: UnaryTransform<S1T, T>>(
|
||||||
|
name: &str,
|
||||||
|
version: Version,
|
||||||
|
height_source: ReadableBoxedVec<Height, S1T>,
|
||||||
|
resolutions: &Resolutions<S1T>,
|
||||||
|
) -> Self
|
||||||
|
where
|
||||||
|
S1T: NumericValue,
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
height: LazyVecFrom1::transformed::<F>(name, version, height_source),
|
||||||
|
resolutions: Box::new(DerivedResolutions::from_derived_computed::<F>(
|
||||||
|
name, version, resolutions,
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn from_computed<F: UnaryTransform<S1T, T>>(
|
pub(crate) fn from_computed<F: UnaryTransform<S1T, T>>(
|
||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
@@ -36,26 +58,38 @@ where
|
|||||||
where
|
where
|
||||||
S1T: NumericValue,
|
S1T: NumericValue,
|
||||||
{
|
{
|
||||||
Self {
|
Self::from_resolutions::<F>(name, version, height_source, &source.resolutions)
|
||||||
height: LazyVecFrom1::transformed::<F>(name, version, height_source),
|
|
||||||
resolutions: Box::new(DerivedResolutions::from_computed::<F>(
|
|
||||||
name, version, source,
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_height_source<F: UnaryTransform<S1T, T>>(
|
pub(crate) fn from_cached_computed<F: UnaryTransform<S1T, T>>(
|
||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
height_source: ReadableBoxedVec<Height, S1T>,
|
height_source: ReadableBoxedVec<Height, S1T>,
|
||||||
indexes: &indexes::Vecs,
|
source: &CachedPerBlock<S1T>,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
S1T: NumericValue,
|
S1T: NumericValue,
|
||||||
|
{
|
||||||
|
Self::from_resolutions::<F>(name, version, height_source, &source.resolutions)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn from_height_source<F: UnaryTransform<S1T, T>, V>(
|
||||||
|
name: &str,
|
||||||
|
version: Version,
|
||||||
|
height_source: V,
|
||||||
|
indexes: &indexes::Vecs,
|
||||||
|
) -> Self
|
||||||
|
where
|
||||||
|
S1T: NumericValue,
|
||||||
|
V: TypedVec<I = Height, T = S1T> + ReadableVec<Height, S1T> + Clone + 'static,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
height: LazyVecFrom1::transformed::<F>(name, version, height_source.clone()),
|
height: LazyVecFrom1::transformed::<F>(
|
||||||
resolutions: Box::new(DerivedResolutions::from_height_source::<F>(
|
name,
|
||||||
|
version,
|
||||||
|
height_source.read_only_boxed_clone(),
|
||||||
|
),
|
||||||
|
resolutions: Box::new(DerivedResolutions::from_height_source::<F, V>(
|
||||||
name,
|
name,
|
||||||
version,
|
version,
|
||||||
height_source,
|
height_source,
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ use brk_types::{
|
|||||||
};
|
};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use vecdb::{ReadableBoxedVec, ReadableCloneableVec, UnaryTransform, VecValue};
|
use vecdb::{ReadableCloneableVec, ReadableVec, TypedVec, UnaryTransform, VecValue};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{ComputedVecValue, NumericValue, PerBlock, PerResolution, Resolutions},
|
internal::{ComputedVecValue, NumericValue, PerResolution, Resolutions},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{LazyTransformLast, MapOption};
|
use super::{LazyTransformLast, MapOption};
|
||||||
@@ -45,25 +45,15 @@ where
|
|||||||
T: VecValue + PartialOrd + JsonSchema + 'static,
|
T: VecValue + PartialOrd + JsonSchema + 'static,
|
||||||
S1T: VecValue + PartialOrd + JsonSchema,
|
S1T: VecValue + PartialOrd + JsonSchema,
|
||||||
{
|
{
|
||||||
pub(crate) fn from_computed<F: UnaryTransform<S1T, T>>(
|
pub(crate) fn from_height_source<F: UnaryTransform<S1T, T>, V>(
|
||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
source: &PerBlock<S1T>,
|
height_source: V,
|
||||||
) -> Self
|
|
||||||
where
|
|
||||||
S1T: NumericValue,
|
|
||||||
{
|
|
||||||
Self::from_derived_computed::<F>(name, version, &source.resolutions)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn from_height_source<F: UnaryTransform<S1T, T>>(
|
|
||||||
name: &str,
|
|
||||||
version: Version,
|
|
||||||
height_source: ReadableBoxedVec<Height, S1T>,
|
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
S1T: NumericValue,
|
S1T: NumericValue,
|
||||||
|
V: TypedVec<I = Height, T = S1T> + ReadableVec<Height, S1T> + Clone + 'static,
|
||||||
{
|
{
|
||||||
let derived = Resolutions::forced_import(name, height_source, version, indexes);
|
let derived = Resolutions::forced_import(name, height_source, version, indexes);
|
||||||
Self::from_derived_computed::<F>(name, version, &derived)
|
Self::from_derived_computed::<F>(name, version, &derived)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ impl PriceWithRatioPerBlock {
|
|||||||
F: FnMut(&mut EagerVec<PcoVec<Height, Cents>>) -> Result<()>,
|
F: FnMut(&mut EagerVec<PcoVec<Height, Cents>>) -> Result<()>,
|
||||||
{
|
{
|
||||||
compute_price(&mut self.cents.height)?;
|
compute_price(&mut self.cents.height)?;
|
||||||
self.compute_ratio(starting_indexes, &prices.cached_spot_cents, exit)
|
self.compute_ratio(starting_indexes, &prices.spot.cents.height, exit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ impl PriceWithRatioExtendedPerBlock {
|
|||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let close_price = &prices.cached_spot_cents;
|
let close_price = &prices.spot.cents.height;
|
||||||
self.base
|
self.base
|
||||||
.compute_ratio(starting_indexes, close_price, exit)?;
|
.compute_ratio(starting_indexes, close_price, exit)?;
|
||||||
self.percentiles.compute(
|
self.percentiles.compute(
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ impl RatioSma {
|
|||||||
|
|
||||||
// Rolling SMAs
|
// Rolling SMAs
|
||||||
for (sma, lookback) in [
|
for (sma, lookback) in [
|
||||||
(&mut self._1w, &blocks.lookback._1w),
|
(&mut self._1w, &blocks.lookback._1w.inner),
|
||||||
(&mut self._1m, &blocks.lookback._1m),
|
(&mut self._1m, &blocks.lookback._1m.inner),
|
||||||
(&mut self._1y, &blocks.lookback._1y),
|
(&mut self._1y, &blocks.lookback._1y.inner),
|
||||||
(&mut self._2y, &blocks.lookback._2y),
|
(&mut self._2y, &blocks.lookback._2y),
|
||||||
(&mut self._4y, &blocks.lookback._4y),
|
(&mut self._4y, &blocks.lookback._4y),
|
||||||
] {
|
] {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ use brk_traversable::Traversable;
|
|||||||
use brk_types::{Height, StoredF32, Version};
|
use brk_types::{Height, StoredF32, Version};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use vecdb::{DeltaAvg, LazyDeltaVec, ReadableCloneableVec};
|
use vecdb::{DeltaAvg, LazyDeltaVec, ReadOnlyClone, ReadableCloneableVec};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, NumericValue, Resolutions, Windows},
|
internal::{NumericValue, Resolutions, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::LazyRollingAvgFromHeight;
|
use super::LazyRollingAvgFromHeight;
|
||||||
@@ -30,25 +30,25 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
cumulative: &(impl ReadableCloneableVec<Height, T> + 'static),
|
cumulative: &(impl ReadableCloneableVec<Height, T> + 'static),
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let cum_source = cumulative.read_only_boxed_clone();
|
let cum_source = cumulative.read_only_boxed_clone();
|
||||||
|
|
||||||
Self(cached_starts.0.map_with_suffix(|suffix, cached_start| {
|
Self(cached_starts.map_with_suffix(|suffix, cached_start| {
|
||||||
let full_name = format!("{name}_{suffix}");
|
let full_name = format!("{name}_{suffix}");
|
||||||
let cached = cached_start.clone();
|
let cached = cached_start.read_only_clone();
|
||||||
let starts_version = cached.version();
|
let starts_version = cached.version();
|
||||||
let avg = LazyDeltaVec::<Height, T, StoredF32, DeltaAvg>::new(
|
let avg = LazyDeltaVec::<Height, T, StoredF32, DeltaAvg>::new(
|
||||||
&full_name,
|
&full_name,
|
||||||
version,
|
version,
|
||||||
cum_source.clone(),
|
cum_source.clone(),
|
||||||
starts_version,
|
starts_version,
|
||||||
move || cached.get(),
|
move || cached.cached(),
|
||||||
);
|
);
|
||||||
let resolutions = Resolutions::forced_import(
|
let resolutions = Resolutions::forced_import(
|
||||||
&full_name,
|
&full_name,
|
||||||
avg.read_only_boxed_clone(),
|
avg.clone(),
|
||||||
version,
|
version,
|
||||||
indexes,
|
indexes,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ use vecdb::{Database, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, LazyRollingAvgsFromHeight, LazyRollingSumsFromHeight, NumericValue,
|
LazyRollingAvgsFromHeight, LazyRollingSumsFromHeight, NumericValue, RollingDistribution,
|
||||||
RollingDistribution, WindowStarts,
|
WindowStartVec, WindowStarts, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ where
|
|||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cumulative: &(impl ReadableCloneableVec<Height, T> + 'static),
|
cumulative: &(impl ReadableCloneableVec<Height, T> + 'static),
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let sum = LazyRollingSumsFromHeight::new(
|
let sum = LazyRollingSumsFromHeight::new(
|
||||||
&format!("{name}_sum"),
|
&format!("{name}_sum"),
|
||||||
|
|||||||
@@ -2,13 +2,16 @@ use brk_traversable::Traversable;
|
|||||||
use brk_types::{Dollars, Height, StoredF32, Version};
|
use brk_types::{Dollars, Height, StoredF32, Version};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use vecdb::{DeltaChange, DeltaRate, LazyDeltaVec, LazyVecFrom1, ReadableCloneableVec, VecValue};
|
use vecdb::{
|
||||||
|
DeltaChange, DeltaRate, LazyDeltaVec, LazyVecFrom1, ReadOnlyClone, ReadableCloneableVec,
|
||||||
|
VecValue,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
BpsType, CachedWindowStarts, CentsType, DerivedResolutions, LazyPerBlock, NumericValue,
|
BpsType, CentsType, DerivedResolutions, LazyPerBlock, NumericValue, Percent, Resolutions,
|
||||||
Percent, Resolutions, Windows,
|
WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,14 +71,14 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
source: &(impl ReadableCloneableVec<Height, S> + 'static),
|
source: &(impl ReadableCloneableVec<Height, S> + 'static),
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let src = source.read_only_boxed_clone();
|
let src = source.read_only_boxed_clone();
|
||||||
|
|
||||||
let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec<Height, Height>| {
|
let make_slot = |suffix: &str, cached_start: &&WindowStartVec| {
|
||||||
let full_name = format!("{name}_{suffix}");
|
let full_name = format!("{name}_{suffix}");
|
||||||
let cached = cached_start.clone();
|
let cached = cached_start.read_only_clone();
|
||||||
let starts_version = cached.version();
|
let starts_version = cached.version();
|
||||||
|
|
||||||
// Absolute change: source[h] - source[ago] as C (via f64)
|
// Absolute change: source[h] - source[ago] as C (via f64)
|
||||||
@@ -86,15 +89,11 @@ where
|
|||||||
starts_version,
|
starts_version,
|
||||||
{
|
{
|
||||||
let cached = cached.clone();
|
let cached = cached.clone();
|
||||||
move || cached.get()
|
move || cached.cached()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let change_resolutions = Resolutions::forced_import(
|
let change_resolutions =
|
||||||
&full_name,
|
Resolutions::forced_import(&full_name, change_vec.clone(), version, indexes);
|
||||||
change_vec.read_only_boxed_clone(),
|
|
||||||
version,
|
|
||||||
indexes,
|
|
||||||
);
|
|
||||||
let absolute = LazyDeltaFromHeight {
|
let absolute = LazyDeltaFromHeight {
|
||||||
height: change_vec,
|
height: change_vec,
|
||||||
resolutions: Box::new(change_resolutions),
|
resolutions: Box::new(change_resolutions),
|
||||||
@@ -107,14 +106,10 @@ where
|
|||||||
version,
|
version,
|
||||||
src.clone(),
|
src.clone(),
|
||||||
starts_version,
|
starts_version,
|
||||||
move || cached.get(),
|
move || cached.cached(),
|
||||||
);
|
|
||||||
let rate_resolutions = Resolutions::forced_import(
|
|
||||||
&rate_bps_name,
|
|
||||||
rate_vec.read_only_boxed_clone(),
|
|
||||||
version,
|
|
||||||
indexes,
|
|
||||||
);
|
);
|
||||||
|
let rate_resolutions =
|
||||||
|
Resolutions::forced_import(&rate_bps_name, rate_vec.clone(), version, indexes);
|
||||||
let bps = LazyDeltaFromHeight {
|
let bps = LazyDeltaFromHeight {
|
||||||
height: rate_vec,
|
height: rate_vec,
|
||||||
resolutions: Box::new(rate_resolutions),
|
resolutions: Box::new(rate_resolutions),
|
||||||
@@ -159,7 +154,7 @@ where
|
|||||||
(absolute, rate)
|
(absolute, rate)
|
||||||
};
|
};
|
||||||
|
|
||||||
let (absolute, rate) = cached_starts.0.map_with_suffix(make_slot).unzip();
|
let (absolute, rate) = cached_starts.map_with_suffix(make_slot).unzip();
|
||||||
|
|
||||||
Self { absolute, rate }
|
Self { absolute, rate }
|
||||||
}
|
}
|
||||||
@@ -206,14 +201,14 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
source: &(impl ReadableCloneableVec<Height, S> + 'static),
|
source: &(impl ReadableCloneableVec<Height, S> + 'static),
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let src = source.read_only_boxed_clone();
|
let src = source.read_only_boxed_clone();
|
||||||
|
|
||||||
let make_slot = |suffix: &str, cached_start: &vecdb::CachedVec<Height, Height>| {
|
let make_slot = |suffix: &str, cached_start: &&WindowStartVec| {
|
||||||
let full_name = format!("{name}_{suffix}");
|
let full_name = format!("{name}_{suffix}");
|
||||||
let cached = cached_start.clone();
|
let cached = cached_start.read_only_clone();
|
||||||
let starts_version = cached.version();
|
let starts_version = cached.version();
|
||||||
|
|
||||||
// Absolute change (cents): source[h] - source[ago] as C (via f64)
|
// Absolute change (cents): source[h] - source[ago] as C (via f64)
|
||||||
@@ -225,12 +220,12 @@ where
|
|||||||
starts_version,
|
starts_version,
|
||||||
{
|
{
|
||||||
let cached = cached.clone();
|
let cached = cached.clone();
|
||||||
move || cached.get()
|
move || cached.cached()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let change_resolutions = Resolutions::forced_import(
|
let change_resolutions = Resolutions::forced_import(
|
||||||
¢s_name,
|
¢s_name,
|
||||||
change_vec.read_only_boxed_clone(),
|
change_vec.clone(),
|
||||||
version,
|
version,
|
||||||
indexes,
|
indexes,
|
||||||
);
|
);
|
||||||
@@ -262,14 +257,10 @@ where
|
|||||||
version,
|
version,
|
||||||
src.clone(),
|
src.clone(),
|
||||||
starts_version,
|
starts_version,
|
||||||
move || cached.get(),
|
move || cached.cached(),
|
||||||
);
|
|
||||||
let rate_resolutions = Resolutions::forced_import(
|
|
||||||
&rate_bps_name,
|
|
||||||
rate_vec.read_only_boxed_clone(),
|
|
||||||
version,
|
|
||||||
indexes,
|
|
||||||
);
|
);
|
||||||
|
let rate_resolutions =
|
||||||
|
Resolutions::forced_import(&rate_bps_name, rate_vec.clone(), version, indexes);
|
||||||
let bps = LazyDeltaFromHeight {
|
let bps = LazyDeltaFromHeight {
|
||||||
height: rate_vec,
|
height: rate_vec,
|
||||||
resolutions: Box::new(rate_resolutions),
|
resolutions: Box::new(rate_resolutions),
|
||||||
@@ -312,7 +303,7 @@ where
|
|||||||
(absolute, rate)
|
(absolute, rate)
|
||||||
};
|
};
|
||||||
|
|
||||||
let (absolute, rate) = cached_starts.0.map_with_suffix(make_slot).unzip();
|
let (absolute, rate) = cached_starts.map_with_suffix(make_slot).unzip();
|
||||||
|
|
||||||
Self { absolute, rate }
|
Self { absolute, rate }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ use vecdb::{ReadableCloneableVec, UnaryTransform};
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts, ComputedVecValue, LazyRollingAvgsFromHeight, LazyRollingDistribution,
|
ComputedVecValue, LazyRollingAvgsFromHeight, LazyRollingDistribution,
|
||||||
LazyRollingSumsFromHeight, NumericValue, RollingComplete,
|
LazyRollingSumsFromHeight, NumericValue, RollingComplete, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ where
|
|||||||
version: Version,
|
version: Version,
|
||||||
cumulative: &(impl ReadableCloneableVec<Height, T> + 'static),
|
cumulative: &(impl ReadableCloneableVec<Height, T> + 'static),
|
||||||
source: &RollingComplete<S1T>,
|
source: &RollingComplete<S1T>,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let sum = LazyRollingSumsFromHeight::new(
|
let sum = LazyRollingSumsFromHeight::new(
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ use brk_traversable::Traversable;
|
|||||||
use brk_types::{Height, Version};
|
use brk_types::{Height, Version};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use vecdb::{DeltaSub, LazyDeltaVec, ReadableCloneableVec};
|
use vecdb::{DeltaSub, LazyDeltaVec, ReadOnlyClone, ReadableCloneableVec};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, NumericValue, Resolutions, Windows},
|
internal::{NumericValue, Resolutions, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::LazyRollingSumFromHeight;
|
use super::LazyRollingSumFromHeight;
|
||||||
@@ -33,28 +33,23 @@ where
|
|||||||
name: &str,
|
name: &str,
|
||||||
version: Version,
|
version: Version,
|
||||||
cumulative: &(impl ReadableCloneableVec<Height, T> + 'static),
|
cumulative: &(impl ReadableCloneableVec<Height, T> + 'static),
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let cum_source = cumulative.read_only_boxed_clone();
|
let cum_source = cumulative.read_only_boxed_clone();
|
||||||
|
|
||||||
Self(cached_starts.0.map_with_suffix(|suffix, cached_start| {
|
Self(cached_starts.map_with_suffix(|suffix, cached_start| {
|
||||||
let full_name = format!("{name}_{suffix}");
|
let full_name = format!("{name}_{suffix}");
|
||||||
let cached = cached_start.clone();
|
let cached = cached_start.read_only_clone();
|
||||||
let starts_version = cached.version();
|
let starts_version = cached.version();
|
||||||
let sum = LazyDeltaVec::<Height, T, T, DeltaSub>::new(
|
let sum = LazyDeltaVec::<Height, T, T, DeltaSub>::new(
|
||||||
&full_name,
|
&full_name,
|
||||||
version,
|
version,
|
||||||
cum_source.clone(),
|
cum_source.clone(),
|
||||||
starts_version,
|
starts_version,
|
||||||
move || cached.get(),
|
move || cached.cached(),
|
||||||
);
|
|
||||||
let resolutions = Resolutions::forced_import(
|
|
||||||
&full_name,
|
|
||||||
sum.read_only_boxed_clone(),
|
|
||||||
version,
|
|
||||||
indexes,
|
|
||||||
);
|
);
|
||||||
|
let resolutions = Resolutions::forced_import(&full_name, sum.clone(), version, indexes);
|
||||||
LazyRollingSumFromHeight {
|
LazyRollingSumFromHeight {
|
||||||
height: sum,
|
height: sum,
|
||||||
resolutions: Box::new(resolutions),
|
resolutions: Box::new(resolutions),
|
||||||
|
|||||||
@@ -18,10 +18,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Cached window starts for lazy rolling computations.
|
pub type WindowStartVec = CachedVec<EagerVec<PcoVec<Height, Height>>>;
|
||||||
/// Clone-cheap (all fields are Arc-backed). Shared across all metrics.
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct CachedWindowStarts(pub Windows<CachedVec<Height, Height>>);
|
|
||||||
|
|
||||||
/// Rolling window start heights — the 4 height-ago vecs (24h, 1w, 1m, 1y).
|
/// Rolling window start heights — the 4 height-ago vecs (24h, 1w, 1m, 1y).
|
||||||
pub type WindowStarts<'a> = Windows<&'a EagerVec<PcoVec<Height, Height>>>;
|
pub type WindowStarts<'a> = Windows<&'a EagerVec<PcoVec<Height, Height>>>;
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ impl Vecs {
|
|||||||
{
|
{
|
||||||
returns.compute_binary::<Cents, Cents, RatioDiffCentsBps32>(
|
returns.compute_binary::<Cents, Cents, RatioDiffCentsBps32>(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&average_price.cents.height,
|
&average_price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -163,7 +163,7 @@ impl Vecs {
|
|||||||
{
|
{
|
||||||
returns.compute_binary::<Cents, Cents, RatioDiffCentsBps32>(
|
returns.compute_binary::<Cents, Cents, RatioDiffCentsBps32>(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&lookback_price.cents.height,
|
&lookback_price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
@@ -266,7 +266,7 @@ impl Vecs {
|
|||||||
{
|
{
|
||||||
returns.compute_binary::<Cents, Cents, RatioDiffCentsBps32>(
|
returns.compute_binary::<Cents, Cents, RatioDiffCentsBps32>(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&average_price.cents.height,
|
&average_price.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ impl Computer {
|
|||||||
)?))
|
)?))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let cached_starts = &blocks.lookback.cached_window_starts;
|
let cached_starts = blocks.lookback.cached_window_starts();
|
||||||
|
|
||||||
let (inputs, outputs, mining, transactions, scripts, pools, cointime) = timed(
|
let (inputs, outputs, mining, transactions, scripts, pools, cointime) = timed(
|
||||||
"Imported inputs/outputs/mining/tx/scripts/pools/cointime",
|
"Imported inputs/outputs/mining/tx/scripts/pools/cointime",
|
||||||
@@ -98,7 +98,7 @@ impl Computer {
|
|||||||
&computed_path,
|
&computed_path,
|
||||||
VERSION,
|
VERSION,
|
||||||
&indexes,
|
&indexes,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?))
|
)?))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ impl Computer {
|
|||||||
&computed_path,
|
&computed_path,
|
||||||
VERSION,
|
VERSION,
|
||||||
&indexes,
|
&indexes,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?))
|
)?))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ impl Computer {
|
|||||||
&computed_path,
|
&computed_path,
|
||||||
VERSION,
|
VERSION,
|
||||||
&indexes,
|
&indexes,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?))
|
)?))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ impl Computer {
|
|||||||
VERSION,
|
VERSION,
|
||||||
indexer,
|
indexer,
|
||||||
&indexes,
|
&indexes,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?))
|
)?))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ impl Computer {
|
|||||||
&computed_path,
|
&computed_path,
|
||||||
VERSION,
|
VERSION,
|
||||||
&indexes,
|
&indexes,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?))
|
)?))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ impl Computer {
|
|||||||
&computed_path,
|
&computed_path,
|
||||||
VERSION,
|
VERSION,
|
||||||
&indexes,
|
&indexes,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?))
|
)?))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ impl Computer {
|
|||||||
&computed_path,
|
&computed_path,
|
||||||
VERSION,
|
VERSION,
|
||||||
&indexes,
|
&indexes,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?);
|
)?);
|
||||||
|
|
||||||
let inputs = inputs_handle.join().unwrap()?;
|
let inputs = inputs_handle.join().unwrap()?;
|
||||||
@@ -208,7 +208,7 @@ impl Computer {
|
|||||||
&computed_path,
|
&computed_path,
|
||||||
VERSION,
|
VERSION,
|
||||||
&indexes,
|
&indexes,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?);
|
)?);
|
||||||
|
|
||||||
let market = market_handle.join().unwrap()?;
|
let market = market_handle.join().unwrap()?;
|
||||||
@@ -225,7 +225,7 @@ impl Computer {
|
|||||||
&indexes,
|
&indexes,
|
||||||
&distribution,
|
&distribution,
|
||||||
&cointime,
|
&cointime,
|
||||||
cached_starts,
|
&cached_starts,
|
||||||
)?))
|
)?))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ impl Vecs {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.high.cents.height.compute_all_time_high(
|
self.high.cents.height.compute_all_time_high(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ impl Vecs {
|
|||||||
self.days_since.height.compute_transform3(
|
self.days_since.height.compute_transform3(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&self.high.cents.height,
|
&self.high.cents.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&indexes.timestamp.monotonic,
|
&indexes.timestamp.monotonic,
|
||||||
|(i, ath, price, ts, slf)| {
|
|(i, ath, price, ts, slf)| {
|
||||||
if ath_ts.is_none() {
|
if ath_ts.is_none() {
|
||||||
@@ -68,7 +68,7 @@ impl Vecs {
|
|||||||
|
|
||||||
self.drawdown.compute_drawdown(
|
self.drawdown.compute_drawdown(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_cents,
|
&prices.spot.cents.height,
|
||||||
&self.high.cents.height,
|
&self.high.cents.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ impl Vecs {
|
|||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let price = &prices.cached_spot_cents;
|
let price = &prices.spot.cents.height;
|
||||||
|
|
||||||
for (price_past, days) in self.price_past.iter_mut_with_days() {
|
for (price_past, days) in self.price_past.iter_mut_with_days() {
|
||||||
let window_starts = blocks.lookback.start_vec(days as usize);
|
let window_starts = blocks.lookback.start_vec(days as usize);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ impl Vecs {
|
|||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let close = &prices.cached_spot_cents;
|
let close = &prices.spot.cents.height;
|
||||||
|
|
||||||
for (sma, period) in [
|
for (sma, period) in [
|
||||||
(&mut self.sma._1w, 7),
|
(&mut self.sma._1w, 7),
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ impl Vecs {
|
|||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let price = &prices.cached_spot_cents;
|
let price = &prices.spot.cents.height;
|
||||||
|
|
||||||
for (min_vec, max_vec, starts) in [
|
for (min_vec, max_vec, starts) in [
|
||||||
(
|
(
|
||||||
&mut self.min._1w.cents.height,
|
&mut self.min._1w.cents.height,
|
||||||
&mut self.max._1w.cents.height,
|
&mut self.max._1w.cents.height,
|
||||||
&blocks.lookback._1w,
|
&blocks.lookback._1w.inner,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
&mut self.min._2w.cents.height,
|
&mut self.min._2w.cents.height,
|
||||||
@@ -29,12 +29,12 @@ impl Vecs {
|
|||||||
(
|
(
|
||||||
&mut self.min._1m.cents.height,
|
&mut self.min._1m.cents.height,
|
||||||
&mut self.max._1m.cents.height,
|
&mut self.max._1m.cents.height,
|
||||||
&blocks.lookback._1m,
|
&blocks.lookback._1m.inner,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
&mut self.min._1y.cents.height,
|
&mut self.min._1y.cents.height,
|
||||||
&mut self.max._1y.cents.height,
|
&mut self.max._1y.cents.height,
|
||||||
&blocks.lookback._1y,
|
&blocks.lookback._1y.inner,
|
||||||
),
|
),
|
||||||
] {
|
] {
|
||||||
min_vec.compute_rolling_min_from_starts(
|
min_vec.compute_rolling_min_from_starts(
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ impl Vecs {
|
|||||||
{
|
{
|
||||||
returns.compute_binary::<Dollars, Dollars, RatioDiffDollarsBps32>(
|
returns.compute_binary::<Dollars, Dollars, RatioDiffDollarsBps32>(
|
||||||
starting_indexes.height,
|
starting_indexes.height,
|
||||||
&prices.cached_spot_usd,
|
&prices.spot.usd.height,
|
||||||
&lookback_price.usd.height,
|
&lookback_price.usd.height,
|
||||||
exit,
|
exit,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub(super) fn compute(
|
|||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
exit: &Exit,
|
exit: &Exit,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let close = &prices.cached_spot_usd;
|
let close = &prices.spot.usd.height;
|
||||||
let ws_fast = blocks.lookback.start_vec(fast_days);
|
let ws_fast = blocks.lookback.start_vec(fast_days);
|
||||||
let ws_slow = blocks.lookback.start_vec(slow_days);
|
let ws_slow = blocks.lookback.start_vec(slow_days);
|
||||||
let ws_signal = blocks.lookback.start_vec(signal_days);
|
let ws_signal = blocks.lookback.start_vec(signal_days);
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ impl Vecs {
|
|||||||
|
|
||||||
let hash_rate = &self.rate.base.height;
|
let hash_rate = &self.rate.base.height;
|
||||||
for (sma, window) in [
|
for (sma, window) in [
|
||||||
(&mut self.rate.sma._1w.height, &lookback._1w),
|
(&mut self.rate.sma._1w.height, &lookback._1w.inner),
|
||||||
(&mut self.rate.sma._1m.height, &lookback._1m),
|
(&mut self.rate.sma._1m.height, &lookback._1m.inner),
|
||||||
(&mut self.rate.sma._2m.height, &lookback._2m),
|
(&mut self.rate.sma._2m.height, &lookback._2m),
|
||||||
(&mut self.rate.sma._1y.height, &lookback._1y),
|
(&mut self.rate.sma._1y.height, &lookback._1y.inner),
|
||||||
] {
|
] {
|
||||||
sma.compute_rolling_average(starting_indexes.height, window, hash_rate, exit)?;
|
sma.compute_rolling_average(starting_indexes.height, window, hash_rate, exit)?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use brk_types::Version;
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts,
|
WindowStartVec, Windows,
|
||||||
db_utils::{finalize_db, open_db},
|
db_utils::{finalize_db, open_db},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -18,7 +18,7 @@ impl Vecs {
|
|||||||
parent_path: &Path,
|
parent_path: &Path,
|
||||||
parent_version: Version,
|
parent_version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let db = open_db(parent_path, super::DB_NAME, 1_000_000)?;
|
let db = open_db(parent_path, super::DB_NAME, 1_000_000)?;
|
||||||
let version = parent_version;
|
let version = parent_version;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use crate::{
|
|||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
AmountPerBlockCumulative, AmountPerBlockCumulativeRolling, AmountPerBlockFull,
|
AmountPerBlockCumulative, AmountPerBlockCumulativeRolling, AmountPerBlockFull,
|
||||||
CachedWindowStarts, LazyPercentRollingWindows, OneMinusBp16, PercentPerBlock,
|
LazyPercentRollingWindows, OneMinusBp16, PercentPerBlock, PercentRollingWindows,
|
||||||
PercentRollingWindows, RatioRollingWindows,
|
RatioRollingWindows, WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let fee_dominance_rolling =
|
let fee_dominance_rolling =
|
||||||
PercentRollingWindows::forced_import(db, "fee_dominance", version, indexes)?;
|
PercentRollingWindows::forced_import(db, "fee_dominance", version, indexes)?;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use vecdb::Database;
|
|||||||
use super::Vecs;
|
use super::Vecs;
|
||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{CachedWindowStarts, PerBlock, PerBlockAggregated},
|
internal::{PerBlock, PerBlockAggregated, WindowStartVec, Windows},
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Vecs {
|
impl Vecs {
|
||||||
@@ -13,7 +13,7 @@ impl Vecs {
|
|||||||
db: &Database,
|
db: &Database,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
total: PerBlockAggregated::forced_import(
|
total: PerBlockAggregated::forced_import(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use brk_types::Version;
|
|||||||
use crate::{
|
use crate::{
|
||||||
indexes,
|
indexes,
|
||||||
internal::{
|
internal::{
|
||||||
CachedWindowStarts,
|
WindowStartVec, Windows,
|
||||||
db_utils::{finalize_db, open_db},
|
db_utils::{finalize_db, open_db},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -18,7 +18,7 @@ impl Vecs {
|
|||||||
parent_path: &Path,
|
parent_path: &Path,
|
||||||
parent_version: Version,
|
parent_version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let db = open_db(parent_path, super::DB_NAME, 20_000_000)?;
|
let db = open_db(parent_path, super::DB_NAME, 20_000_000)?;
|
||||||
let version = parent_version;
|
let version = parent_version;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use vecdb::{BinaryTransform, Database, Exit, ReadableVec, Rw, StorageMode, Versi
|
|||||||
use crate::{
|
use crate::{
|
||||||
blocks, indexes,
|
blocks, indexes,
|
||||||
internal::{
|
internal::{
|
||||||
AmountPerBlockCumulativeRolling, CachedWindowStarts, MaskSats, PercentRollingWindows,
|
AmountPerBlockCumulativeRolling, MaskSats, PercentRollingWindows, RatioU64Bp16,
|
||||||
RatioU64Bp16,
|
WindowStartVec, Windows,
|
||||||
},
|
},
|
||||||
mining, prices,
|
mining, prices,
|
||||||
};
|
};
|
||||||
@@ -33,7 +33,7 @@ impl Vecs {
|
|||||||
slug: PoolSlug,
|
slug: PoolSlug,
|
||||||
version: Version,
|
version: Version,
|
||||||
indexes: &indexes::Vecs,
|
indexes: &indexes::Vecs,
|
||||||
cached_starts: &CachedWindowStarts,
|
cached_starts: &Windows<&WindowStartVec>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let suffix = |s: &str| format!("{}_{s}", slug);
|
let suffix = |s: &str| format!("{}_{s}", slug);
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user