mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
computer: snapshot
This commit is contained in:
@@ -370,8 +370,8 @@ impl<T: DeserializeOwned, D: DeserializeOwned> RangeBuilder<T, D> {
|
||||
|
||||
|
||||
// Static index arrays
|
||||
const _I1: &[Index] = &[Index::Minute10, Index::Minute30, Index::Hour1, Index::Hour4, Index::Hour12, Index::Day1, Index::Day3, Index::Week1, Index::Month1, Index::Month3, Index::Month6, Index::Year1, Index::Year10, Index::HalvingEpoch, Index::DifficultyEpoch, Index::Height];
|
||||
const _I2: &[Index] = &[Index::Minute10, Index::Minute30, Index::Hour1, Index::Hour4, Index::Hour12, Index::Day1, Index::Day3, Index::Week1, Index::Month1, Index::Month3, Index::Month6, Index::Year1, Index::Year10, Index::HalvingEpoch, Index::DifficultyEpoch];
|
||||
const _I1: &[Index] = &[Index::Minute10, Index::Minute30, Index::Hour1, Index::Hour4, Index::Hour12, Index::Day1, Index::Day3, Index::Week1, Index::Month1, Index::Month3, Index::Month6, Index::Year1, Index::Year10, Index::Halving, Index::Epoch, Index::Height];
|
||||
const _I2: &[Index] = &[Index::Minute10, Index::Minute30, Index::Hour1, Index::Hour4, Index::Hour12, Index::Day1, Index::Day3, Index::Week1, Index::Month1, Index::Month3, Index::Month6, Index::Year1, Index::Year10, Index::Halving, Index::Epoch];
|
||||
const _I3: &[Index] = &[Index::Minute10];
|
||||
const _I4: &[Index] = &[Index::Minute30];
|
||||
const _I5: &[Index] = &[Index::Hour1];
|
||||
@@ -385,8 +385,8 @@ const _I12: &[Index] = &[Index::Month3];
|
||||
const _I13: &[Index] = &[Index::Month6];
|
||||
const _I14: &[Index] = &[Index::Year1];
|
||||
const _I15: &[Index] = &[Index::Year10];
|
||||
const _I16: &[Index] = &[Index::HalvingEpoch];
|
||||
const _I17: &[Index] = &[Index::DifficultyEpoch];
|
||||
const _I16: &[Index] = &[Index::Halving];
|
||||
const _I17: &[Index] = &[Index::Epoch];
|
||||
const _I18: &[Index] = &[Index::Height];
|
||||
const _I19: &[Index] = &[Index::TxIndex];
|
||||
const _I20: &[Index] = &[Index::TxInIndex];
|
||||
@@ -433,8 +433,8 @@ impl<T: DeserializeOwned> MetricPattern1By<T> {
|
||||
pub fn month6(&self) -> DateMetricEndpointBuilder<T> { _dep(&self.client, &self.name, Index::Month6) }
|
||||
pub fn year1(&self) -> DateMetricEndpointBuilder<T> { _dep(&self.client, &self.name, Index::Year1) }
|
||||
pub fn year10(&self) -> DateMetricEndpointBuilder<T> { _dep(&self.client, &self.name, Index::Year10) }
|
||||
pub fn halvingepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::HalvingEpoch) }
|
||||
pub fn difficultyepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::DifficultyEpoch) }
|
||||
pub fn halvingepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::Halving) }
|
||||
pub fn difficultyepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::Epoch) }
|
||||
pub fn height(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::Height) }
|
||||
}
|
||||
|
||||
@@ -462,8 +462,8 @@ impl<T: DeserializeOwned> MetricPattern2By<T> {
|
||||
pub fn month6(&self) -> DateMetricEndpointBuilder<T> { _dep(&self.client, &self.name, Index::Month6) }
|
||||
pub fn year1(&self) -> DateMetricEndpointBuilder<T> { _dep(&self.client, &self.name, Index::Year1) }
|
||||
pub fn year10(&self) -> DateMetricEndpointBuilder<T> { _dep(&self.client, &self.name, Index::Year10) }
|
||||
pub fn halvingepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::HalvingEpoch) }
|
||||
pub fn difficultyepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::DifficultyEpoch) }
|
||||
pub fn halvingepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::Halving) }
|
||||
pub fn difficultyepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::Epoch) }
|
||||
}
|
||||
|
||||
pub struct MetricPattern2<T> { name: Arc<str>, pub by: MetricPattern2By<T> }
|
||||
@@ -659,7 +659,7 @@ impl<T: DeserializeOwned> MetricPattern<T> for MetricPattern15<T> { fn get(&self
|
||||
|
||||
pub struct MetricPattern16By<T> { client: Arc<BrkClientBase>, name: Arc<str>, _marker: std::marker::PhantomData<T> }
|
||||
impl<T: DeserializeOwned> MetricPattern16By<T> {
|
||||
pub fn halvingepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::HalvingEpoch) }
|
||||
pub fn halvingepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::Halving) }
|
||||
}
|
||||
|
||||
pub struct MetricPattern16<T> { name: Arc<str>, pub by: MetricPattern16By<T> }
|
||||
@@ -673,7 +673,7 @@ impl<T: DeserializeOwned> MetricPattern<T> for MetricPattern16<T> { fn get(&self
|
||||
|
||||
pub struct MetricPattern17By<T> { client: Arc<BrkClientBase>, name: Arc<str>, _marker: std::marker::PhantomData<T> }
|
||||
impl<T: DeserializeOwned> MetricPattern17By<T> {
|
||||
pub fn difficultyepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::DifficultyEpoch) }
|
||||
pub fn difficultyepoch(&self) -> MetricEndpointBuilder<T> { _ep(&self.client, &self.name, Index::Epoch) }
|
||||
}
|
||||
|
||||
pub struct MetricPattern17<T> { name: Arc<str>, pub by: MetricPattern17By<T> }
|
||||
@@ -2894,7 +2894,7 @@ pub struct MetricsTree_Blocks_Difficulty {
|
||||
pub raw: MetricPattern1<StoredF64>,
|
||||
pub as_hash: MetricPattern1<StoredF64>,
|
||||
pub adjustment: BpsPercentRatioPattern,
|
||||
pub epoch: MetricPattern1<DifficultyEpoch>,
|
||||
pub epoch: MetricPattern1<Epoch>,
|
||||
pub blocks_before_next_adjustment: MetricPattern1<StoredU32>,
|
||||
pub days_before_next_adjustment: MetricPattern1<StoredF32>,
|
||||
}
|
||||
@@ -3067,7 +3067,7 @@ impl MetricsTree_Blocks_Count {
|
||||
|
||||
/// Metrics tree node.
|
||||
pub struct MetricsTree_Blocks_Halving {
|
||||
pub epoch: MetricPattern1<HalvingEpoch>,
|
||||
pub epoch: MetricPattern1<Halving>,
|
||||
pub blocks_before_next_halving: MetricPattern1<StoredU32>,
|
||||
pub days_before_next_halving: MetricPattern1<StoredF32>,
|
||||
}
|
||||
@@ -4082,8 +4082,8 @@ pub struct MetricsTree_Indexes_Height {
|
||||
pub hour12: MetricPattern18<Hour12>,
|
||||
pub day1: MetricPattern18<Day1>,
|
||||
pub day3: MetricPattern18<Day3>,
|
||||
pub difficultyepoch: MetricPattern18<DifficultyEpoch>,
|
||||
pub halvingepoch: MetricPattern18<HalvingEpoch>,
|
||||
pub difficultyepoch: MetricPattern18<Epoch>,
|
||||
pub halvingepoch: MetricPattern18<Halving>,
|
||||
pub week1: MetricPattern18<Week1>,
|
||||
pub month1: MetricPattern18<Month1>,
|
||||
pub month3: MetricPattern18<Month3>,
|
||||
@@ -4119,7 +4119,7 @@ impl MetricsTree_Indexes_Height {
|
||||
|
||||
/// Metrics tree node.
|
||||
pub struct MetricsTree_Indexes_Difficultyepoch {
|
||||
pub identity: MetricPattern17<DifficultyEpoch>,
|
||||
pub identity: MetricPattern17<Epoch>,
|
||||
pub first_height: MetricPattern17<Height>,
|
||||
pub height_count: MetricPattern17<StoredU64>,
|
||||
}
|
||||
@@ -4136,7 +4136,7 @@ impl MetricsTree_Indexes_Difficultyepoch {
|
||||
|
||||
/// Metrics tree node.
|
||||
pub struct MetricsTree_Indexes_Halvingepoch {
|
||||
pub identity: MetricPattern16<HalvingEpoch>,
|
||||
pub identity: MetricPattern16<Halving>,
|
||||
pub first_height: MetricPattern16<Height>,
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ pub enum Filter {
|
||||
Term(Term), // STH/LTH
|
||||
Time(TimeFilter), // Age-based
|
||||
Amount(AmountFilter), // Value-based
|
||||
Epoch(HalvingEpoch), // Halving epoch
|
||||
Epoch(Halving), // Halving epoch
|
||||
Year(Year), // Calendar year
|
||||
Type(OutputType), // P2PKH, P2TR, etc.
|
||||
}
|
||||
@@ -48,5 +48,5 @@ ctx.full_name(&filter, "min_age_150d"); // "utxos_min_age_150d"
|
||||
## Built On
|
||||
|
||||
- `brk_error` for error handling
|
||||
- `brk_types` for `Sats`, `HalvingEpoch`, `OutputType`
|
||||
- `brk_types` for `Sats`, `Halving`, `OutputType`
|
||||
- `brk_traversable` for data structure traversal
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{HalvingEpoch, Height};
|
||||
use brk_types::{Halving, Height};
|
||||
use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
||||
use serde::Serialize;
|
||||
|
||||
use super::{CohortName, Filter};
|
||||
|
||||
/// Epoch values
|
||||
pub const EPOCH_VALUES: ByEpoch<HalvingEpoch> = ByEpoch {
|
||||
_0: HalvingEpoch::new(0),
|
||||
_1: HalvingEpoch::new(1),
|
||||
_2: HalvingEpoch::new(2),
|
||||
_3: HalvingEpoch::new(3),
|
||||
_4: HalvingEpoch::new(4),
|
||||
pub const EPOCH_VALUES: ByEpoch<Halving> = ByEpoch {
|
||||
_0: Halving::new(0),
|
||||
_1: Halving::new(1),
|
||||
_2: Halving::new(2),
|
||||
_3: Halving::new(3),
|
||||
_4: Halving::new(4),
|
||||
};
|
||||
|
||||
/// Epoch filters
|
||||
@@ -108,16 +108,16 @@ impl<T> ByEpoch<T> {
|
||||
}
|
||||
|
||||
pub fn mut_vec_from_height(&mut self, height: Height) -> &mut T {
|
||||
let epoch = HalvingEpoch::from(height);
|
||||
if epoch == HalvingEpoch::new(0) {
|
||||
let epoch = Halving::from(height);
|
||||
if epoch == Halving::new(0) {
|
||||
&mut self._0
|
||||
} else if epoch == HalvingEpoch::new(1) {
|
||||
} else if epoch == Halving::new(1) {
|
||||
&mut self._1
|
||||
} else if epoch == HalvingEpoch::new(2) {
|
||||
} else if epoch == Halving::new(2) {
|
||||
&mut self._2
|
||||
} else if epoch == HalvingEpoch::new(3) {
|
||||
} else if epoch == Halving::new(3) {
|
||||
&mut self._3
|
||||
} else if epoch == HalvingEpoch::new(4) {
|
||||
} else if epoch == Halving::new(4) {
|
||||
&mut self._4
|
||||
} else {
|
||||
todo!("")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use brk_types::{HalvingEpoch, OutputType, Sats, Year};
|
||||
use brk_types::{Halving, OutputType, Sats, Year};
|
||||
|
||||
use super::{AmountFilter, CohortContext, Term, TimeFilter};
|
||||
|
||||
@@ -8,7 +8,7 @@ pub enum Filter {
|
||||
Term(Term),
|
||||
Time(TimeFilter),
|
||||
Amount(AmountFilter),
|
||||
Epoch(HalvingEpoch),
|
||||
Epoch(Halving),
|
||||
Class(Year),
|
||||
Type(OutputType),
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_types::{DifficultyAdjustment, DifficultyEpoch, Height};
|
||||
use brk_types::{DifficultyAdjustment, Epoch, Height};
|
||||
use vecdb::ReadableVec;
|
||||
|
||||
use crate::Query;
|
||||
@@ -23,7 +23,7 @@ impl Query {
|
||||
let current_epoch = computer
|
||||
.indexes
|
||||
.height
|
||||
.difficulty
|
||||
.epoch
|
||||
.collect_one(current_height)
|
||||
.unwrap();
|
||||
let current_epoch_usize: usize = current_epoch.into();
|
||||
@@ -31,7 +31,7 @@ impl Query {
|
||||
// Get epoch start height
|
||||
let epoch_start_height = computer
|
||||
.indexes
|
||||
.difficulty
|
||||
.epoch
|
||||
.first_height
|
||||
.collect_one(current_epoch)
|
||||
.unwrap();
|
||||
@@ -48,7 +48,7 @@ impl Query {
|
||||
.blocks
|
||||
.time
|
||||
.timestamp
|
||||
.difficulty
|
||||
.epoch
|
||||
.collect_one(current_epoch)
|
||||
.unwrap();
|
||||
let current_timestamp = indexer
|
||||
@@ -87,10 +87,10 @@ impl Query {
|
||||
|
||||
// Calculate previous retarget using stored difficulty values
|
||||
let previous_retarget = if current_epoch_usize > 0 {
|
||||
let prev_epoch = DifficultyEpoch::from(current_epoch_usize - 1);
|
||||
let prev_epoch = Epoch::from(current_epoch_usize - 1);
|
||||
let prev_epoch_start = computer
|
||||
.indexes
|
||||
.difficulty
|
||||
.epoch
|
||||
.first_height
|
||||
.collect_one(prev_epoch)
|
||||
.unwrap();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use brk_computer::Computer;
|
||||
use brk_types::{DifficultyAdjustmentEntry, DifficultyEpoch, Height};
|
||||
use brk_types::{DifficultyAdjustmentEntry, Epoch, Height};
|
||||
use vecdb::{ReadableVec, Ro, VecIndex};
|
||||
|
||||
/// Iterate over difficulty epochs within a height range.
|
||||
@@ -11,25 +11,25 @@ pub fn iter_difficulty_epochs(
|
||||
let start_epoch = computer
|
||||
.indexes
|
||||
.height
|
||||
.difficulty
|
||||
.epoch
|
||||
.collect_one(Height::from(start_height))
|
||||
.unwrap_or_default();
|
||||
let end_epoch = computer
|
||||
.indexes
|
||||
.height
|
||||
.difficulty
|
||||
.epoch
|
||||
.collect_one(Height::from(end_height))
|
||||
.unwrap_or_default();
|
||||
|
||||
let epoch_to_height = &computer.indexes.difficulty.first_height;
|
||||
let epoch_to_timestamp = &computer.blocks.time.timestamp.difficulty;
|
||||
let epoch_to_difficulty = &computer.blocks.difficulty.raw.difficulty;
|
||||
let epoch_to_height = &computer.indexes.epoch.first_height;
|
||||
let epoch_to_timestamp = &computer.blocks.time.timestamp.epoch;
|
||||
let epoch_to_difficulty = &computer.blocks.difficulty.raw.epoch;
|
||||
|
||||
let mut results = Vec::with_capacity(end_epoch.to_usize() - start_epoch.to_usize() + 1);
|
||||
let mut prev_difficulty: Option<f64> = None;
|
||||
|
||||
for epoch_usize in start_epoch.to_usize()..=end_epoch.to_usize() {
|
||||
let epoch = DifficultyEpoch::from(epoch_usize);
|
||||
let epoch = Epoch::from(epoch_usize);
|
||||
let epoch_height = epoch_to_height.collect_one(epoch).unwrap_or_default();
|
||||
|
||||
// Skip epochs before our start height but track difficulty
|
||||
|
||||
@@ -11,7 +11,7 @@ Work with Bitcoin primitives (heights, satoshis, addresses, transactions) throug
|
||||
- **Bitcoin primitives**: `Height`, `Sats`, `Txid`, `BlockHash`, `Outpoint` with full arithmetic and conversion support
|
||||
- **Address types**: All output types (P2PK33, P2PK65, P2PKH, P2MS, P2SH, P2WPKH, P2WSH, P2TR, P2A, OP_RETURN) with address index variants
|
||||
- **Time indexes**: `DateIndex`, `WeekIndex`, `MonthIndex`, `QuarterIndex`, `SemesterIndex`, `YearIndex`, `DecadeIndex` with cross-index conversion
|
||||
- **Protocol types**: `DifficultyEpoch`, `HalvingEpoch`, `TxVersion`, `RawLocktime`
|
||||
- **Protocol types**: `Epoch`, `Halving`, `TxVersion`, `RawLocktime`
|
||||
- **Financial types**: `Dollars`, `Cents`, `OHLC` (Open/High/Low/Close)
|
||||
- **Serialization**: Serde + JSON Schema generation via schemars
|
||||
- **Compression**: PCO (Pco) derive for columnar compression in vecdb
|
||||
|
||||
@@ -25,30 +25,30 @@ pub const BLOCKS_PER_DIFF_EPOCHS: u32 = 2016;
|
||||
Pco,
|
||||
JsonSchema,
|
||||
)]
|
||||
pub struct DifficultyEpoch(u16);
|
||||
pub struct Epoch(u16);
|
||||
|
||||
impl From<u16> for DifficultyEpoch {
|
||||
impl From<u16> for Epoch {
|
||||
#[inline]
|
||||
fn from(value: u16) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for DifficultyEpoch {
|
||||
impl From<usize> for Epoch {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DifficultyEpoch> for usize {
|
||||
impl From<Epoch> for usize {
|
||||
#[inline]
|
||||
fn from(value: DifficultyEpoch) -> Self {
|
||||
fn from(value: Epoch) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
}
|
||||
|
||||
impl Add for DifficultyEpoch {
|
||||
impl Add for Epoch {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Self) -> Self::Output {
|
||||
@@ -56,13 +56,13 @@ impl Add for DifficultyEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign for DifficultyEpoch {
|
||||
impl AddAssign for Epoch {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
*self = *self + rhs
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<usize> for DifficultyEpoch {
|
||||
impl Add<usize> for Epoch {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: usize) -> Self::Output {
|
||||
@@ -70,37 +70,37 @@ impl Add<usize> for DifficultyEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl Div<usize> for DifficultyEpoch {
|
||||
impl Div<usize> for Epoch {
|
||||
type Output = Self;
|
||||
fn div(self, rhs: usize) -> Self::Output {
|
||||
Self::from(self.0 as usize / rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Height> for DifficultyEpoch {
|
||||
impl From<Height> for Epoch {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
Self((u32::from(value) / BLOCKS_PER_DIFF_EPOCHS) as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckedSub for DifficultyEpoch {
|
||||
impl CheckedSub for Epoch {
|
||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||
self.0.checked_sub(rhs.0).map(Self)
|
||||
}
|
||||
}
|
||||
|
||||
impl PrintableIndex for DifficultyEpoch {
|
||||
impl PrintableIndex for Epoch {
|
||||
fn to_string() -> &'static str {
|
||||
"difficultyepoch"
|
||||
}
|
||||
|
||||
fn to_possible_strings() -> &'static [&'static str] {
|
||||
&["difficulty", "difficultyepoch", "diff"]
|
||||
&["epoch", "difficulty", "difficultyepoch", "diff"]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for DifficultyEpoch {
|
||||
impl std::fmt::Display for Epoch {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = itoa::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
@@ -108,7 +108,7 @@ impl std::fmt::Display for DifficultyEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl Formattable for DifficultyEpoch {
|
||||
impl Formattable for Epoch {
|
||||
#[inline(always)]
|
||||
fn write_to(&self, buf: &mut Vec<u8>) {
|
||||
let mut b = itoa::Buffer::new();
|
||||
@@ -116,7 +116,7 @@ impl Formattable for DifficultyEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<f64> for DifficultyEpoch {
|
||||
impl From<f64> for Epoch {
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
let value = value.max(0.0);
|
||||
@@ -124,9 +124,9 @@ impl From<f64> for DifficultyEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DifficultyEpoch> for f64 {
|
||||
impl From<Epoch> for f64 {
|
||||
#[inline]
|
||||
fn from(value: DifficultyEpoch) -> Self {
|
||||
fn from(value: Epoch) -> Self {
|
||||
value.0 as f64
|
||||
}
|
||||
}
|
||||
@@ -25,36 +25,36 @@ pub const BLOCKS_PER_HALVING: u32 = 210_000;
|
||||
Pco,
|
||||
JsonSchema,
|
||||
)]
|
||||
pub struct HalvingEpoch(u8);
|
||||
pub struct Halving(u8);
|
||||
|
||||
impl HalvingEpoch {
|
||||
impl Halving {
|
||||
pub const fn new(value: u8) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u8> for HalvingEpoch {
|
||||
impl From<u8> for Halving {
|
||||
#[inline]
|
||||
fn from(value: u8) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for HalvingEpoch {
|
||||
impl From<usize> for Halving {
|
||||
#[inline]
|
||||
fn from(value: usize) -> Self {
|
||||
Self(value as u8)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HalvingEpoch> for usize {
|
||||
impl From<Halving> for usize {
|
||||
#[inline]
|
||||
fn from(value: HalvingEpoch) -> Self {
|
||||
fn from(value: Halving) -> Self {
|
||||
value.0 as usize
|
||||
}
|
||||
}
|
||||
|
||||
impl Add for HalvingEpoch {
|
||||
impl Add for Halving {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Self) -> Self::Output {
|
||||
@@ -62,13 +62,13 @@ impl Add for HalvingEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign for HalvingEpoch {
|
||||
impl AddAssign for Halving {
|
||||
fn add_assign(&mut self, rhs: Self) {
|
||||
*self = *self + rhs
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<usize> for HalvingEpoch {
|
||||
impl Add<usize> for Halving {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: usize) -> Self::Output {
|
||||
@@ -76,27 +76,27 @@ impl Add<usize> for HalvingEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Height> for HalvingEpoch {
|
||||
impl From<Height> for Halving {
|
||||
#[inline]
|
||||
fn from(value: Height) -> Self {
|
||||
Self((u32::from(value) / BLOCKS_PER_HALVING) as u8)
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckedSub for HalvingEpoch {
|
||||
impl CheckedSub for Halving {
|
||||
fn checked_sub(self, rhs: Self) -> Option<Self> {
|
||||
self.0.checked_sub(rhs.0).map(Self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Div<usize> for HalvingEpoch {
|
||||
impl Div<usize> for Halving {
|
||||
type Output = Self;
|
||||
fn div(self, rhs: usize) -> Self::Output {
|
||||
Self::from(self.0 as usize / rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl PrintableIndex for HalvingEpoch {
|
||||
impl PrintableIndex for Halving {
|
||||
fn to_string() -> &'static str {
|
||||
"halvingepoch"
|
||||
}
|
||||
@@ -106,7 +106,7 @@ impl PrintableIndex for HalvingEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for HalvingEpoch {
|
||||
impl std::fmt::Display for Halving {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut buf = itoa::Buffer::new();
|
||||
let str = buf.format(self.0);
|
||||
@@ -114,7 +114,7 @@ impl std::fmt::Display for HalvingEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl Formattable for HalvingEpoch {
|
||||
impl Formattable for Halving {
|
||||
#[inline(always)]
|
||||
fn write_to(&self, buf: &mut Vec<u8>) {
|
||||
let mut b = itoa::Buffer::new();
|
||||
@@ -122,7 +122,7 @@ impl Formattable for HalvingEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<f64> for HalvingEpoch {
|
||||
impl From<f64> for Halving {
|
||||
#[inline]
|
||||
fn from(value: f64) -> Self {
|
||||
let value = value.max(0.0);
|
||||
@@ -130,9 +130,9 @@ impl From<f64> for HalvingEpoch {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HalvingEpoch> for f64 {
|
||||
impl From<Halving> for f64 {
|
||||
#[inline]
|
||||
fn from(value: HalvingEpoch) -> Self {
|
||||
fn from(value: Halving) -> Self {
|
||||
value.0 as f64
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ use vecdb::{Bytes, CheckedSub, Formattable, Pco, PrintableIndex, Stamp};
|
||||
|
||||
use crate::{BLOCKS_PER_DIFF_EPOCHS, BLOCKS_PER_HALVING, FromCoarserIndex};
|
||||
|
||||
use super::{DifficultyEpoch, HalvingEpoch, StoredU64};
|
||||
use super::{Epoch, Halving, StoredU64};
|
||||
|
||||
/// Block height
|
||||
#[derive(
|
||||
@@ -292,22 +292,22 @@ impl Formattable for Height {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromCoarserIndex<DifficultyEpoch> for Height {
|
||||
fn min_from(coarser: DifficultyEpoch) -> usize {
|
||||
impl FromCoarserIndex<Epoch> for Height {
|
||||
fn min_from(coarser: Epoch) -> usize {
|
||||
usize::from(coarser) * BLOCKS_PER_DIFF_EPOCHS as usize
|
||||
}
|
||||
|
||||
fn max_from_(coarser: DifficultyEpoch) -> usize {
|
||||
fn max_from_(coarser: Epoch) -> usize {
|
||||
(usize::from(coarser) + 1) * BLOCKS_PER_DIFF_EPOCHS as usize - 1
|
||||
}
|
||||
}
|
||||
|
||||
impl FromCoarserIndex<HalvingEpoch> for Height {
|
||||
fn min_from(coarser: HalvingEpoch) -> usize {
|
||||
impl FromCoarserIndex<Halving> for Height {
|
||||
fn min_from(coarser: Halving) -> usize {
|
||||
usize::from(coarser) * BLOCKS_PER_HALVING as usize
|
||||
}
|
||||
|
||||
fn max_from_(coarser: HalvingEpoch) -> usize {
|
||||
fn max_from_(coarser: Halving) -> usize {
|
||||
(usize::from(coarser) + 1) * BLOCKS_PER_HALVING as usize - 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ use vecdb::PrintableIndex;
|
||||
use crate::PairOutputIndex;
|
||||
|
||||
use super::{
|
||||
Date, Day1, Day3, DifficultyEpoch, EmptyAddressIndex, EmptyOutputIndex, FundedAddressIndex,
|
||||
HalvingEpoch, Height, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, Month6,
|
||||
Date, Day1, Day3, Epoch, EmptyAddressIndex, EmptyOutputIndex, FundedAddressIndex,
|
||||
Halving, Height, Hour1, Hour4, Hour12, Minute10, Minute30, Month1, Month3, Month6,
|
||||
OpReturnIndex, P2AAddressIndex, P2MSOutputIndex, P2PK33AddressIndex, P2PK65AddressIndex,
|
||||
P2PKHAddressIndex, P2SHAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex,
|
||||
Timestamp, TxInIndex, TxIndex, TxOutIndex, UnknownOutputIndex, Week1, Year1, Year10,
|
||||
@@ -36,8 +36,8 @@ pub enum Index {
|
||||
Month6,
|
||||
Year1,
|
||||
Year10,
|
||||
HalvingEpoch,
|
||||
DifficultyEpoch,
|
||||
Halving,
|
||||
Epoch,
|
||||
Height,
|
||||
TxIndex,
|
||||
TxInIndex,
|
||||
@@ -75,8 +75,8 @@ impl Index {
|
||||
Self::Month6,
|
||||
Self::Year1,
|
||||
Self::Year10,
|
||||
Self::HalvingEpoch,
|
||||
Self::DifficultyEpoch,
|
||||
Self::Halving,
|
||||
Self::Epoch,
|
||||
Self::Height,
|
||||
Self::TxIndex,
|
||||
Self::TxInIndex,
|
||||
@@ -114,8 +114,8 @@ impl Index {
|
||||
Self::Month6 => Month6::to_possible_strings(),
|
||||
Self::Year1 => Year1::to_possible_strings(),
|
||||
Self::Year10 => Year10::to_possible_strings(),
|
||||
Self::HalvingEpoch => HalvingEpoch::to_possible_strings(),
|
||||
Self::DifficultyEpoch => DifficultyEpoch::to_possible_strings(),
|
||||
Self::Halving => Halving::to_possible_strings(),
|
||||
Self::Epoch => Epoch::to_possible_strings(),
|
||||
Self::Height => Height::to_possible_strings(),
|
||||
Self::TxIndex => TxIndex::to_possible_strings(),
|
||||
Self::TxInIndex => TxInIndex::to_possible_strings(),
|
||||
@@ -160,8 +160,8 @@ impl Index {
|
||||
Self::Month6 => <Month6 as PrintableIndex>::to_string(),
|
||||
Self::Year1 => <Year1 as PrintableIndex>::to_string(),
|
||||
Self::Year10 => <Year10 as PrintableIndex>::to_string(),
|
||||
Self::HalvingEpoch => <HalvingEpoch as PrintableIndex>::to_string(),
|
||||
Self::DifficultyEpoch => <DifficultyEpoch as PrintableIndex>::to_string(),
|
||||
Self::Halving => <Halving as PrintableIndex>::to_string(),
|
||||
Self::Epoch => <Epoch as PrintableIndex>::to_string(),
|
||||
Self::Height => <Height as PrintableIndex>::to_string(),
|
||||
Self::TxIndex => <TxIndex as PrintableIndex>::to_string(),
|
||||
Self::TxInIndex => <TxInIndex as PrintableIndex>::to_string(),
|
||||
@@ -188,7 +188,7 @@ impl Index {
|
||||
/// Used for rate limiting to account for expensive lazy computations.
|
||||
pub const fn cost_multiplier(&self) -> usize {
|
||||
match self {
|
||||
Self::DifficultyEpoch => 60,
|
||||
Self::Epoch => 60,
|
||||
_ => 1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ mod deser;
|
||||
mod difficultyadjustment;
|
||||
mod difficultyadjustmententry;
|
||||
mod difficultyentry;
|
||||
mod difficultyepoch;
|
||||
mod epoch;
|
||||
mod diskusage;
|
||||
mod dollars;
|
||||
mod emptyaddressdata;
|
||||
@@ -71,7 +71,7 @@ mod formatresponse;
|
||||
mod from_coarser;
|
||||
mod fundedaddressdata;
|
||||
mod fundedaddressindex;
|
||||
mod halvingepoch;
|
||||
mod halving;
|
||||
mod hashrateentry;
|
||||
mod hashratesummary;
|
||||
mod health;
|
||||
@@ -249,7 +249,7 @@ pub use deser::*;
|
||||
pub use difficultyadjustment::*;
|
||||
pub use difficultyadjustmententry::*;
|
||||
pub use difficultyentry::*;
|
||||
pub use difficultyepoch::*;
|
||||
pub use epoch::*;
|
||||
pub use diskusage::*;
|
||||
pub use dollars::*;
|
||||
pub use emptyaddressdata::*;
|
||||
@@ -263,7 +263,7 @@ pub use formatresponse::*;
|
||||
pub use from_coarser::*;
|
||||
pub use fundedaddressdata::*;
|
||||
pub use fundedaddressindex::*;
|
||||
pub use halvingepoch::*;
|
||||
pub use halving::*;
|
||||
pub use hashrateentry::*;
|
||||
pub use hashratesummary::*;
|
||||
pub use health::*;
|
||||
|
||||
@@ -466,7 +466,7 @@ mod tests {
|
||||
// - height_cumulative (renamed to "cumulative") → direct leaf at Height
|
||||
// - day1 → branch with sum/cumulative at Day1
|
||||
// - week1 (flattened from dates) → branch with sum/cumulative at Week1
|
||||
// - difficultyepoch → branch with sum/cumulative at DifficultyEpoch
|
||||
// - difficultyepoch → branch with sum/cumulative at Epoch
|
||||
let tree = branch(vec![
|
||||
("cumulative", leaf("metric_cumulative", Index::Height)),
|
||||
(
|
||||
@@ -486,10 +486,10 @@ mod tests {
|
||||
(
|
||||
"difficultyepoch",
|
||||
branch(vec![
|
||||
("sum", leaf("metric_sum", Index::DifficultyEpoch)),
|
||||
("sum", leaf("metric_sum", Index::Epoch)),
|
||||
(
|
||||
"cumulative",
|
||||
leaf("metric_cumulative", Index::DifficultyEpoch),
|
||||
leaf("metric_cumulative", Index::Epoch),
|
||||
),
|
||||
]),
|
||||
),
|
||||
@@ -501,19 +501,19 @@ mod tests {
|
||||
TreeNode::Branch(map) => {
|
||||
assert_eq!(map.len(), 2);
|
||||
|
||||
// sum: Day1, Week1, DifficultyEpoch (NOT Height)
|
||||
// sum: Day1, Week1, Epoch (NOT Height)
|
||||
let sum_indexes = get_leaf_indexes(map.get("sum").unwrap()).unwrap();
|
||||
assert!(!sum_indexes.contains(&Index::Height));
|
||||
assert!(sum_indexes.contains(&Index::Day1));
|
||||
assert!(sum_indexes.contains(&Index::Week1));
|
||||
assert!(sum_indexes.contains(&Index::DifficultyEpoch));
|
||||
assert!(sum_indexes.contains(&Index::Epoch));
|
||||
|
||||
// cumulative: Height, Day1, Week1, DifficultyEpoch
|
||||
// cumulative: Height, Day1, Week1, Epoch
|
||||
let cumulative_indexes = get_leaf_indexes(map.get("cumulative").unwrap()).unwrap();
|
||||
assert!(cumulative_indexes.contains(&Index::Height));
|
||||
assert!(cumulative_indexes.contains(&Index::Day1));
|
||||
assert!(cumulative_indexes.contains(&Index::Week1));
|
||||
assert!(cumulative_indexes.contains(&Index::DifficultyEpoch));
|
||||
assert!(cumulative_indexes.contains(&Index::Epoch));
|
||||
}
|
||||
_ => panic!("Expected branch"),
|
||||
}
|
||||
|
||||
@@ -280,14 +280,14 @@
|
||||
- [Date](type-aliases/Date.md)
|
||||
- [DateIndex](type-aliases/DateIndex.md)
|
||||
- [DecadeIndex](type-aliases/DecadeIndex.md)
|
||||
- [DifficultyEpoch](type-aliases/DifficultyEpoch.md)
|
||||
- [Epoch](type-aliases/Epoch.md)
|
||||
- [Dollars](type-aliases/Dollars.md)
|
||||
- [EmptyAddressIndex](type-aliases/EmptyAddressIndex.md)
|
||||
- [EmptyOutputIndex](type-aliases/EmptyOutputIndex.md)
|
||||
- [FeeRate](type-aliases/FeeRate.md)
|
||||
- [Format](type-aliases/Format.md)
|
||||
- [FundedAddressIndex](type-aliases/FundedAddressIndex.md)
|
||||
- [HalvingEpoch](type-aliases/HalvingEpoch.md)
|
||||
- [Halving](type-aliases/Halving.md)
|
||||
- [Height](type-aliases/Height.md)
|
||||
- [Hex](type-aliases/Hex.md)
|
||||
- [High](type-aliases/High.md)
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
***
|
||||
|
||||
[brk-client](../globals.md) / DifficultyEpoch
|
||||
[brk-client](../globals.md) / Epoch
|
||||
|
||||
# Type Alias: DifficultyEpoch
|
||||
# Type Alias: Epoch
|
||||
|
||||
> **DifficultyEpoch**\<\> = `number`
|
||||
> **Epoch**\<\> = `number`
|
||||
|
||||
Defined in: [Developer/brk/modules/brk-client/index.js:281](https://github.com/bitcoinresearchkit/brk/blob/4a06caec672337d1974d77b021e6d10711049dbe/modules/brk-client/index.js#L281)
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
***
|
||||
|
||||
[brk-client](../globals.md) / HalvingEpoch
|
||||
[brk-client](../globals.md) / Halving
|
||||
|
||||
# Type Alias: HalvingEpoch
|
||||
# Type Alias: Halving
|
||||
|
||||
> **HalvingEpoch**\<\> = `number`
|
||||
> **Halving**\<\> = `number`
|
||||
|
||||
Defined in: [Developer/brk/modules/brk-client/index.js:330](https://github.com/bitcoinresearchkit/brk/blob/4a06caec672337d1974d77b021e6d10711049dbe/modules/brk-client/index.js#L330)
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
* @property {number} difficulty - Difficulty value.
|
||||
* @property {Height} height - Block height of the adjustment.
|
||||
*/
|
||||
/** @typedef {number} DifficultyEpoch */
|
||||
/** @typedef {number} Epoch */
|
||||
/**
|
||||
* Disk usage of the indexed data
|
||||
*
|
||||
@@ -361,7 +361,7 @@
|
||||
* @property {CentsSquaredSats} investorCapRaw - The investor capitalization: Σ(price² × sats)
|
||||
*/
|
||||
/** @typedef {TypeIndex} FundedAddressIndex */
|
||||
/** @typedef {number} HalvingEpoch */
|
||||
/** @typedef {number} Halving */
|
||||
/**
|
||||
* A single hashrate data point.
|
||||
*
|
||||
@@ -3718,7 +3718,7 @@ function create_24hPattern(client, acc) {
|
||||
* @property {MetricPattern1<StoredF64>} raw
|
||||
* @property {MetricPattern1<StoredF64>} asHash
|
||||
* @property {BpsPercentRatioPattern} adjustment
|
||||
* @property {MetricPattern1<DifficultyEpoch>} epoch
|
||||
* @property {MetricPattern1<Epoch>} epoch
|
||||
* @property {MetricPattern1<StoredU32>} blocksBeforeNextAdjustment
|
||||
* @property {MetricPattern1<StoredF32>} daysBeforeNextAdjustment
|
||||
*/
|
||||
@@ -3797,7 +3797,7 @@ function create_24hPattern(client, acc) {
|
||||
|
||||
/**
|
||||
* @typedef {Object} MetricsTree_Blocks_Halving
|
||||
* @property {MetricPattern1<HalvingEpoch>} epoch
|
||||
* @property {MetricPattern1<Halving>} epoch
|
||||
* @property {MetricPattern1<StoredU32>} blocksBeforeNextHalving
|
||||
* @property {MetricPattern1<StoredF32>} daysBeforeNextHalving
|
||||
*/
|
||||
@@ -4238,8 +4238,8 @@ function create_24hPattern(client, acc) {
|
||||
* @property {MetricPattern18<Hour12>} hour12
|
||||
* @property {MetricPattern18<Day1>} day1
|
||||
* @property {MetricPattern18<Day3>} day3
|
||||
* @property {MetricPattern18<DifficultyEpoch>} difficultyepoch
|
||||
* @property {MetricPattern18<HalvingEpoch>} halvingepoch
|
||||
* @property {MetricPattern18<Epoch>} difficultyepoch
|
||||
* @property {MetricPattern18<Halving>} halvingepoch
|
||||
* @property {MetricPattern18<Week1>} week1
|
||||
* @property {MetricPattern18<Month1>} month1
|
||||
* @property {MetricPattern18<Month3>} month3
|
||||
@@ -4251,14 +4251,14 @@ function create_24hPattern(client, acc) {
|
||||
|
||||
/**
|
||||
* @typedef {Object} MetricsTree_Indexes_Difficultyepoch
|
||||
* @property {MetricPattern17<DifficultyEpoch>} identity
|
||||
* @property {MetricPattern17<Epoch>} identity
|
||||
* @property {MetricPattern17<Height>} firstHeight
|
||||
* @property {MetricPattern17<StoredU64>} heightCount
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} MetricsTree_Indexes_Halvingepoch
|
||||
* @property {MetricPattern16<HalvingEpoch>} identity
|
||||
* @property {MetricPattern16<Halving>} identity
|
||||
* @property {MetricPattern16<Height>} firstHeight
|
||||
*/
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ Limit = int
|
||||
Date = int
|
||||
Day1 = int
|
||||
Day3 = int
|
||||
DifficultyEpoch = int
|
||||
Epoch = int
|
||||
# US Dollar amount as floating point
|
||||
Dollars = float
|
||||
EmptyAddressIndex = TypeIndex
|
||||
@@ -96,7 +96,7 @@ EmptyOutputIndex = TypeIndex
|
||||
# Fee rate in sats/vB
|
||||
FeeRate = float
|
||||
FundedAddressIndex = TypeIndex
|
||||
HalvingEpoch = int
|
||||
Halving = int
|
||||
# Hex-encoded string
|
||||
Hex = str
|
||||
# Highest price value for a time period
|
||||
@@ -3011,7 +3011,7 @@ class MetricsTree_Blocks_Difficulty:
|
||||
self.raw: MetricPattern1[StoredF64] = MetricPattern1(client, 'difficulty')
|
||||
self.as_hash: MetricPattern1[StoredF64] = MetricPattern1(client, 'difficulty_as_hash')
|
||||
self.adjustment: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'difficulty_adjustment')
|
||||
self.epoch: MetricPattern1[DifficultyEpoch] = MetricPattern1(client, 'difficulty_epoch')
|
||||
self.epoch: MetricPattern1[Epoch] = MetricPattern1(client, 'difficulty_epoch')
|
||||
self.blocks_before_next_adjustment: MetricPattern1[StoredU32] = MetricPattern1(client, 'blocks_before_next_difficulty_adjustment')
|
||||
self.days_before_next_adjustment: MetricPattern1[StoredF32] = MetricPattern1(client, 'days_before_next_difficulty_adjustment')
|
||||
|
||||
@@ -3094,7 +3094,7 @@ class MetricsTree_Blocks_Halving:
|
||||
"""Metrics tree node."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, base_path: str = ''):
|
||||
self.epoch: MetricPattern1[HalvingEpoch] = MetricPattern1(client, 'halving_epoch')
|
||||
self.epoch: MetricPattern1[Halving] = MetricPattern1(client, 'halving_epoch')
|
||||
self.blocks_before_next_halving: MetricPattern1[StoredU32] = MetricPattern1(client, 'blocks_before_next_halving')
|
||||
self.days_before_next_halving: MetricPattern1[StoredF32] = MetricPattern1(client, 'days_before_next_halving')
|
||||
|
||||
@@ -3573,8 +3573,8 @@ class MetricsTree_Indexes_Height:
|
||||
self.hour12: MetricPattern18[Hour12] = MetricPattern18(client, 'hour12')
|
||||
self.day1: MetricPattern18[Day1] = MetricPattern18(client, 'day1')
|
||||
self.day3: MetricPattern18[Day3] = MetricPattern18(client, 'day3')
|
||||
self.difficultyepoch: MetricPattern18[DifficultyEpoch] = MetricPattern18(client, 'difficultyepoch')
|
||||
self.halvingepoch: MetricPattern18[HalvingEpoch] = MetricPattern18(client, 'halvingepoch')
|
||||
self.difficultyepoch: MetricPattern18[Epoch] = MetricPattern18(client, 'difficultyepoch')
|
||||
self.halvingepoch: MetricPattern18[Halving] = MetricPattern18(client, 'halvingepoch')
|
||||
self.week1: MetricPattern18[Week1] = MetricPattern18(client, 'week1')
|
||||
self.month1: MetricPattern18[Month1] = MetricPattern18(client, 'month1')
|
||||
self.month3: MetricPattern18[Month3] = MetricPattern18(client, 'month3')
|
||||
@@ -3587,7 +3587,7 @@ class MetricsTree_Indexes_Difficultyepoch:
|
||||
"""Metrics tree node."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, base_path: str = ''):
|
||||
self.identity: MetricPattern17[DifficultyEpoch] = MetricPattern17(client, 'difficultyepoch')
|
||||
self.identity: MetricPattern17[Epoch] = MetricPattern17(client, 'difficultyepoch')
|
||||
self.first_height: MetricPattern17[Height] = MetricPattern17(client, 'first_height')
|
||||
self.height_count: MetricPattern17[StoredU64] = MetricPattern17(client, 'height_count')
|
||||
|
||||
@@ -3595,7 +3595,7 @@ class MetricsTree_Indexes_Halvingepoch:
|
||||
"""Metrics tree node."""
|
||||
|
||||
def __init__(self, client: BrkClientBase, base_path: str = ''):
|
||||
self.identity: MetricPattern16[HalvingEpoch] = MetricPattern16(client, 'halvingepoch')
|
||||
self.identity: MetricPattern16[Halving] = MetricPattern16(client, 'halvingepoch')
|
||||
self.first_height: MetricPattern16[Height] = MetricPattern16(client, 'first_height')
|
||||
|
||||
class MetricsTree_Indexes_Minute10:
|
||||
|
||||
Reference in New Issue
Block a user