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