mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-26 07:39:59 -07:00
computer: snapshot
This commit is contained in:
@@ -37,7 +37,7 @@ impl Vecs {
|
||||
// Compute epoch by height
|
||||
self.epoch.height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&indexes.height.difficulty,
|
||||
&indexes.height.epoch,
|
||||
|(h, epoch, ..)| (h, epoch),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{BasisPointsSigned32, DifficultyEpoch, StoredF32, StoredF64, StoredU32};
|
||||
use brk_types::{BasisPointsSigned32, Epoch, StoredF32, StoredF64, StoredU32};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::{ComputedPerBlock, Resolutions, PercentPerBlock};
|
||||
@@ -8,7 +8,7 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub raw: Resolutions<StoredF64>,
|
||||
pub as_hash: ComputedPerBlock<StoredF64, M>,
|
||||
pub adjustment: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
pub epoch: ComputedPerBlock<DifficultyEpoch, M>,
|
||||
pub epoch: ComputedPerBlock<Epoch, M>,
|
||||
pub blocks_before_next_adjustment: ComputedPerBlock<StoredU32, M>,
|
||||
pub days_before_next_adjustment: ComputedPerBlock<StoredF32, M>,
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{HalvingEpoch, StoredF32, StoredU32};
|
||||
use brk_types::{Halving, StoredF32, StoredU32};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::ComputedPerBlock;
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub epoch: ComputedPerBlock<HalvingEpoch, M>,
|
||||
pub epoch: ComputedPerBlock<Halving, M>,
|
||||
pub blocks_before_next_halving: ComputedPerBlock<StoredU32, M>,
|
||||
pub days_before_next_halving: ComputedPerBlock<StoredF32, M>,
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ impl TimestampIndexes {
|
||||
year1: period!(year1),
|
||||
year10: period!(year10),
|
||||
halving: epoch!(halving),
|
||||
difficulty: epoch!(difficulty),
|
||||
epoch: epoch!(difficulty),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Date, Day1, Day3, DifficultyEpoch, HalvingEpoch, Height, Hour1, Hour4, Hour12, Indexes,
|
||||
Date, Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Indexes,
|
||||
Minute10, Minute30, Month1, Month3, Month6, Timestamp, Week1, Year1, Year10,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
@@ -39,8 +39,8 @@ pub struct TimestampIndexes<M: StorageMode = Rw>(
|
||||
LazyVecFrom1<Month6, Timestamp, Month6, Height>,
|
||||
LazyVecFrom1<Year1, Timestamp, Year1, Height>,
|
||||
LazyVecFrom1<Year10, Timestamp, Year10, Height>,
|
||||
M::Stored<EagerVec<PcoVec<HalvingEpoch, Timestamp>>>,
|
||||
M::Stored<EagerVec<PcoVec<DifficultyEpoch, Timestamp>>>,
|
||||
M::Stored<EagerVec<PcoVec<Halving, Timestamp>>>,
|
||||
M::Stored<EagerVec<PcoVec<Epoch, Timestamp>>>,
|
||||
>,
|
||||
);
|
||||
|
||||
@@ -65,13 +65,13 @@ impl TimestampIndexes {
|
||||
&indexer.vecs.blocks.timestamp,
|
||||
exit,
|
||||
)?;
|
||||
self.difficulty.compute_indirect_sequential(
|
||||
self.epoch.compute_indirect_sequential(
|
||||
indexes
|
||||
.height
|
||||
.difficulty
|
||||
.epoch
|
||||
.collect_one(prev_height)
|
||||
.unwrap_or_default(),
|
||||
&indexes.difficulty.first_height,
|
||||
&indexes.epoch.first_height,
|
||||
&indexer.vecs.blocks.timestamp,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{DifficultyEpoch, Height, StoredU64, Version};
|
||||
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<DifficultyEpoch, DifficultyEpoch>>>,
|
||||
pub first_height: M::Stored<EagerVec<PcoVec<DifficultyEpoch, Height>>>,
|
||||
pub height_count: M::Stored<EagerVec<PcoVec<DifficultyEpoch, StoredU64>>>,
|
||||
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 {
|
||||
@@ -1,13 +1,13 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{HalvingEpoch, Height, Version};
|
||||
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<HalvingEpoch, HalvingEpoch>>>,
|
||||
pub first_height: M::Stored<EagerVec<PcoVec<HalvingEpoch, Height>>>,
|
||||
pub identity: M::Stored<EagerVec<PcoVec<Halving, Halving>>>,
|
||||
pub first_height: M::Stored<EagerVec<PcoVec<Halving, Height>>>,
|
||||
}
|
||||
|
||||
impl Vecs {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Day1, Day3, DifficultyEpoch, HalvingEpoch, Height, Hour1, Hour4, Hour12, Minute10, Minute30,
|
||||
Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30,
|
||||
Month1, Month3, Month6, StoredU64, Version, Week1, Year1, Year10,
|
||||
};
|
||||
use vecdb::{Database, EagerVec, ImportableVec, PcoVec, Rw, StorageMode};
|
||||
@@ -17,8 +17,8 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub hour12: M::Stored<EagerVec<PcoVec<Height, Hour12>>>,
|
||||
pub day1: M::Stored<EagerVec<PcoVec<Height, Day1>>>,
|
||||
pub day3: M::Stored<EagerVec<PcoVec<Height, Day3>>>,
|
||||
pub difficulty: M::Stored<EagerVec<PcoVec<Height, DifficultyEpoch>>>,
|
||||
pub halving: M::Stored<EagerVec<PcoVec<Height, HalvingEpoch>>>,
|
||||
pub epoch: M::Stored<EagerVec<PcoVec<Height, Epoch>>>,
|
||||
pub halving: M::Stored<EagerVec<PcoVec<Height, Halving>>>,
|
||||
pub week1: M::Stored<EagerVec<PcoVec<Height, Week1>>>,
|
||||
pub month1: M::Stored<EagerVec<PcoVec<Height, Month1>>>,
|
||||
pub month3: M::Stored<EagerVec<PcoVec<Height, Month3>>>,
|
||||
@@ -39,7 +39,7 @@ impl Vecs {
|
||||
hour12: EagerVec::forced_import(db, "hour12", version)?,
|
||||
day1: EagerVec::forced_import(db, "day1", version)?,
|
||||
day3: EagerVec::forced_import(db, "day3", version)?,
|
||||
difficulty: EagerVec::forced_import(db, "difficulty", version)?,
|
||||
epoch: EagerVec::forced_import(db, "difficulty", version)?,
|
||||
halving: EagerVec::forced_import(db, "halving", version)?,
|
||||
week1: EagerVec::forced_import(db, "week1", version)?,
|
||||
month1: EagerVec::forced_import(db, "month1", version)?,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
mod address;
|
||||
mod day1;
|
||||
mod day3;
|
||||
mod difficulty;
|
||||
mod epoch;
|
||||
mod halving;
|
||||
mod height;
|
||||
mod hour1;
|
||||
@@ -38,7 +38,7 @@ use crate::{
|
||||
pub use address::Vecs as AddressVecs;
|
||||
pub use day1::Vecs as Day1Vecs;
|
||||
pub use day3::Vecs as Day3Vecs;
|
||||
pub use difficulty::Vecs as DifficultyVecs;
|
||||
pub use epoch::Vecs as EpochVecs;
|
||||
pub use halving::Vecs as HalvingVecs;
|
||||
pub use height::Vecs as HeightVecs;
|
||||
pub use hour1::Vecs as Hour1Vecs;
|
||||
@@ -63,7 +63,7 @@ pub struct Vecs<M: StorageMode = Rw> {
|
||||
db: Database,
|
||||
pub address: AddressVecs,
|
||||
pub height: HeightVecs<M>,
|
||||
pub difficulty: DifficultyVecs<M>,
|
||||
pub epoch: EpochVecs<M>,
|
||||
pub halving: HalvingVecs<M>,
|
||||
pub minute10: Minute10Vecs<M>,
|
||||
pub minute30: Minute30Vecs<M>,
|
||||
@@ -96,7 +96,7 @@ impl Vecs {
|
||||
let this = Self {
|
||||
address: AddressVecs::forced_import(version, indexer),
|
||||
height: HeightVecs::forced_import(&db, version)?,
|
||||
difficulty: DifficultyVecs::forced_import(&db, version)?,
|
||||
epoch: EpochVecs::forced_import(&db, version)?,
|
||||
halving: HalvingVecs::forced_import(&db, version)?,
|
||||
minute10: Minute10Vecs::forced_import(&db, version)?,
|
||||
minute30: Minute30Vecs::forced_import(&db, version)?,
|
||||
@@ -318,30 +318,30 @@ impl Vecs {
|
||||
) -> Result<()> {
|
||||
let starting_difficulty = self
|
||||
.height
|
||||
.difficulty
|
||||
.epoch
|
||||
.collect_one(prev_height)
|
||||
.unwrap_or_default();
|
||||
|
||||
self.height.difficulty.compute_from_index(
|
||||
self.height.epoch.compute_from_index(
|
||||
starting_indexes.height,
|
||||
&indexer.vecs.blocks.weight,
|
||||
exit,
|
||||
)?;
|
||||
self.difficulty.first_height.compute_first_per_index(
|
||||
self.epoch.first_height.compute_first_per_index(
|
||||
starting_indexes.height,
|
||||
&self.height.difficulty,
|
||||
&self.height.epoch,
|
||||
exit,
|
||||
)?;
|
||||
self.difficulty.identity.compute_from_index(
|
||||
self.epoch.identity.compute_from_index(
|
||||
starting_difficulty,
|
||||
&self.difficulty.first_height,
|
||||
&self.epoch.first_height,
|
||||
exit,
|
||||
)?;
|
||||
self.difficulty
|
||||
self.epoch
|
||||
.height_count
|
||||
.compute_count_from_indexes(
|
||||
starting_difficulty,
|
||||
&self.difficulty.first_height,
|
||||
&self.epoch.first_height,
|
||||
&blocks_time.date,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -17,5 +17,5 @@ pub struct PerResolution<M10, M30, H1, H4, H12, D1, D3, W1, Mo1, Mo3, Mo6, Y1, Y
|
||||
pub year1: Y1,
|
||||
pub year10: Y10,
|
||||
pub halving: HE,
|
||||
pub difficulty: DE,
|
||||
pub epoch: DE,
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use brk_error::Result;
|
||||
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Day1, Day3, DifficultyEpoch, HalvingEpoch, Height, Hour1, Hour4, Hour12, Indexes, Minute10,
|
||||
Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Indexes, Minute10,
|
||||
Minute30, Month1, Month3, Month6, Version, Week1, Year1, Year10,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
@@ -35,8 +35,8 @@ pub struct EagerIndexes<T, M: StorageMode = Rw>(
|
||||
<M as StorageMode>::Stored<EagerVec<PcoVec<Month6, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<PcoVec<Year1, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<PcoVec<Year10, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<PcoVec<HalvingEpoch, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<PcoVec<DifficultyEpoch, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<PcoVec<Halving, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<PcoVec<Epoch, T>>>,
|
||||
>,
|
||||
)
|
||||
where
|
||||
@@ -68,7 +68,7 @@ where
|
||||
year1: per_period!(),
|
||||
year10: per_period!(),
|
||||
halving: per_period!(),
|
||||
difficulty: per_period!(),
|
||||
epoch: per_period!(),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ where
|
||||
period!(year1);
|
||||
period!(year10);
|
||||
period!(halving);
|
||||
period!(difficulty);
|
||||
period!(epoch);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -157,7 +157,7 @@ where
|
||||
period!(year1);
|
||||
period!(year10);
|
||||
period!(halving);
|
||||
period!(difficulty);
|
||||
period!(epoch);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -204,7 +204,7 @@ where
|
||||
period!(year1);
|
||||
period!(year10);
|
||||
period!(halving);
|
||||
period!(difficulty);
|
||||
period!(epoch);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Day1, Day3, DifficultyEpoch, HalvingEpoch, Hour1, Hour4, Hour12, Minute10, Minute30, Month1,
|
||||
Day1, Day3, Epoch, Halving, Hour1, Hour4, Hour12, Minute10, Minute30, Month1,
|
||||
Month3, Month6, Version, Week1, Year1, Year10,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
@@ -27,8 +27,8 @@ pub struct LazyEagerIndexes<T, S>(
|
||||
LazyVecFrom1<Month6, T, Month6, S>,
|
||||
LazyVecFrom1<Year1, T, Year1, S>,
|
||||
LazyVecFrom1<Year10, T, Year10, S>,
|
||||
LazyVecFrom1<HalvingEpoch, T, HalvingEpoch, S>,
|
||||
LazyVecFrom1<DifficultyEpoch, T, DifficultyEpoch, S>,
|
||||
LazyVecFrom1<Halving, T, Halving, S>,
|
||||
LazyVecFrom1<Epoch, T, Epoch, S>,
|
||||
>,
|
||||
)
|
||||
where
|
||||
@@ -70,7 +70,7 @@ where
|
||||
year1: period!(year1),
|
||||
year10: period!(year10),
|
||||
halving: period!(halving),
|
||||
difficulty: period!(difficulty),
|
||||
epoch: period!(epoch),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Day1, Day3, DifficultyEpoch, HalvingEpoch, Height, Hour1, Hour4, Hour12, Minute10, Minute30,
|
||||
Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30,
|
||||
Month1, Month3, Month6, Version, Week1, Year1, Year10,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
@@ -29,8 +29,8 @@ where
|
||||
pub month6: LazyVecFrom1<Month6, T, Month6, Month6>,
|
||||
pub year1: LazyVecFrom1<Year1, T, Year1, Year1>,
|
||||
pub year10: LazyVecFrom1<Year10, T, Year10, Year10>,
|
||||
pub halving: LazyVecFrom1<HalvingEpoch, T, HalvingEpoch, HalvingEpoch>,
|
||||
pub difficulty: LazyVecFrom1<DifficultyEpoch, T, DifficultyEpoch, DifficultyEpoch>,
|
||||
pub halving: LazyVecFrom1<Halving, T, Halving, Halving>,
|
||||
pub epoch: LazyVecFrom1<Epoch, T, Epoch, Epoch>,
|
||||
}
|
||||
|
||||
impl<T: VecValue + Formattable + Serialize + JsonSchema> ConstantVecs<T> {
|
||||
@@ -50,8 +50,8 @@ impl<T: VecValue + Formattable + Serialize + JsonSchema> ConstantVecs<T> {
|
||||
+ UnaryTransform<Month6, T>
|
||||
+ UnaryTransform<Year1, T>
|
||||
+ UnaryTransform<Year10, T>
|
||||
+ UnaryTransform<HalvingEpoch, T>
|
||||
+ UnaryTransform<DifficultyEpoch, T>,
|
||||
+ UnaryTransform<Halving, T>
|
||||
+ UnaryTransform<Epoch, T>,
|
||||
{
|
||||
macro_rules! period {
|
||||
($idx:ident) => {
|
||||
@@ -79,7 +79,7 @@ impl<T: VecValue + Formattable + Serialize + JsonSchema> ConstantVecs<T> {
|
||||
year1: period!(year1),
|
||||
year10: period!(year10),
|
||||
halving: period!(halving),
|
||||
difficulty: period!(difficulty),
|
||||
epoch: period!(epoch),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Day1, Day3, DifficultyEpoch, FromCoarserIndex, HalvingEpoch, Height, Hour1, Hour4, Hour12,
|
||||
Day1, Day3, Epoch, FromCoarserIndex, Halving, Height, Hour1, Hour4, Hour12,
|
||||
Minute10, Minute30, Month1, Month3, Month6, Version, Week1, Year1, Year10,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
@@ -32,8 +32,8 @@ pub struct Resolutions<T>(
|
||||
LazyAggVec<Month6, Option<T>, Height, Height, T>,
|
||||
LazyAggVec<Year1, Option<T>, Height, Height, T>,
|
||||
LazyAggVec<Year10, Option<T>, Height, Height, T>,
|
||||
LazyAggVec<HalvingEpoch, T, Height, HalvingEpoch>,
|
||||
LazyAggVec<DifficultyEpoch, T, Height, DifficultyEpoch>,
|
||||
LazyAggVec<Halving, T, Height, Halving>,
|
||||
LazyAggVec<Epoch, T, Height, Epoch>,
|
||||
>,
|
||||
)
|
||||
where
|
||||
@@ -128,7 +128,7 @@ where
|
||||
year1: period!(year1),
|
||||
year10: period!(year10),
|
||||
halving: epoch!(halving),
|
||||
difficulty: epoch!(difficulty),
|
||||
epoch: epoch!(epoch),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Day1, Day3, DifficultyEpoch, HalvingEpoch, Height, Hour1, Hour4, Hour12, Minute10, Minute30,
|
||||
Day1, Day3, Epoch, Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30,
|
||||
Month1, Month3, Month6, Version, Week1, Year1, Year10,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
@@ -34,8 +34,8 @@ pub struct DerivedResolutions<T, S1T = T>(
|
||||
LazyTransformLast<Month6, Option<T>, Option<S1T>>,
|
||||
LazyTransformLast<Year1, Option<T>, Option<S1T>>,
|
||||
LazyTransformLast<Year10, Option<T>, Option<S1T>>,
|
||||
LazyTransformLast<HalvingEpoch, T, S1T>,
|
||||
LazyTransformLast<DifficultyEpoch, T, S1T>,
|
||||
LazyTransformLast<Halving, T, S1T>,
|
||||
LazyTransformLast<Epoch, T, S1T>,
|
||||
>,
|
||||
)
|
||||
where
|
||||
@@ -110,7 +110,7 @@ where
|
||||
year1: period!(year1),
|
||||
year10: period!(year10),
|
||||
halving: epoch!(halving),
|
||||
difficulty: epoch!(difficulty),
|
||||
epoch: epoch!(epoch),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ where
|
||||
year1: period!(year1),
|
||||
year10: period!(year10),
|
||||
halving: epoch!(halving),
|
||||
difficulty: epoch!(difficulty),
|
||||
epoch: epoch!(epoch),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_types::{
|
||||
Close, Day1, Day3, DifficultyEpoch, HalvingEpoch, Height, High, Hour1, Hour4, Hour12, Low,
|
||||
Close, Day1, Day3, Epoch, Halving, Height, High, Hour1, Hour4, Hour12, Low,
|
||||
Minute10, Minute30, Month1, Month3, Month6, OHLCCents, OHLCDollars, OHLCSats, Open, StoredU64,
|
||||
Week1, Year1, Year10,
|
||||
};
|
||||
@@ -114,16 +114,16 @@ impl UnaryTransform<Year10, StoredU64> for BlockCountTarget {
|
||||
}
|
||||
}
|
||||
|
||||
impl UnaryTransform<HalvingEpoch, StoredU64> for BlockCountTarget {
|
||||
impl UnaryTransform<Halving, StoredU64> for BlockCountTarget {
|
||||
#[inline(always)]
|
||||
fn apply(_: HalvingEpoch) -> StoredU64 {
|
||||
fn apply(_: Halving) -> StoredU64 {
|
||||
StoredU64::from(TARGET_BLOCKS_PER_HALVING)
|
||||
}
|
||||
}
|
||||
|
||||
impl UnaryTransform<DifficultyEpoch, StoredU64> for BlockCountTarget {
|
||||
impl UnaryTransform<Epoch, StoredU64> for BlockCountTarget {
|
||||
#[inline(always)]
|
||||
fn apply(_: DifficultyEpoch) -> StoredU64 {
|
||||
fn apply(_: Epoch) -> StoredU64 {
|
||||
StoredU64::from(2016u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use brk_error::Result;
|
||||
use brk_indexer::Indexer;
|
||||
use brk_types::{BasisPoints16, CheckedSub, HalvingEpoch, Indexes, Sats};
|
||||
use brk_types::{BasisPoints16, CheckedSub, Halving, Indexes, Sats};
|
||||
use vecdb::{Exit, ReadableVec, VecIndex};
|
||||
|
||||
use super::Vecs;
|
||||
@@ -102,7 +102,7 @@ impl Vecs {
|
||||
starting_indexes.height,
|
||||
&self.subsidy.base.sats.height,
|
||||
|(height, subsidy, ..)| {
|
||||
let halving = HalvingEpoch::from(height);
|
||||
let halving = Halving::from(height);
|
||||
let expected = Sats::FIFTY_BTC / 2_usize.pow(halving.to_usize() as u32);
|
||||
(height, expected.checked_sub(subsidy).unwrap())
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
Cents, Close, Day1, Day3, DifficultyEpoch, HalvingEpoch, High, Hour1, Hour4, Hour12, Indexes,
|
||||
Cents, Close, Day1, Day3, Epoch, Halving, High, Hour1, Hour4, Hour12, Indexes,
|
||||
Low, Minute10, Minute30, Month1, Month3, Month6, OHLCCents, Open, Version, Week1, Year1,
|
||||
Year10,
|
||||
};
|
||||
@@ -36,8 +36,8 @@ pub struct OhlcVecs<T, M: StorageMode = Rw>(
|
||||
<M as StorageMode>::Stored<EagerVec<BytesVec<Month6, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<BytesVec<Year1, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<BytesVec<Year10, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<BytesVec<HalvingEpoch, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<BytesVec<DifficultyEpoch, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<BytesVec<Halving, T>>>,
|
||||
<M as StorageMode>::Stored<EagerVec<BytesVec<Epoch, T>>>,
|
||||
>,
|
||||
)
|
||||
where
|
||||
@@ -73,7 +73,7 @@ where
|
||||
year1: per_period!(),
|
||||
year10: per_period!(),
|
||||
halving: per_period!(),
|
||||
difficulty: per_period!(),
|
||||
epoch: per_period!(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ impl OhlcVecs<OHLCCents> {
|
||||
period!(year1);
|
||||
period!(year10);
|
||||
epoch!(halving);
|
||||
epoch!(difficulty);
|
||||
epoch!(epoch);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -193,8 +193,8 @@ pub struct LazyOhlcVecs<T, S>(
|
||||
LazyVecFrom1<Month6, T, Month6, S>,
|
||||
LazyVecFrom1<Year1, T, Year1, S>,
|
||||
LazyVecFrom1<Year10, T, Year10, S>,
|
||||
LazyVecFrom1<HalvingEpoch, T, HalvingEpoch, S>,
|
||||
LazyVecFrom1<DifficultyEpoch, T, DifficultyEpoch, S>,
|
||||
LazyVecFrom1<Halving, T, Halving, S>,
|
||||
LazyVecFrom1<Epoch, T, Epoch, S>,
|
||||
>,
|
||||
)
|
||||
where
|
||||
@@ -236,7 +236,7 @@ where
|
||||
year1: period!(year1),
|
||||
year10: period!(year10),
|
||||
halving: period!(halving),
|
||||
difficulty: period!(difficulty),
|
||||
epoch: period!(epoch),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user