mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-10 10:38:14 -07:00
global: add hash related datasets
This commit is contained in:
@@ -10,6 +10,8 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::Height;
|
||||
|
||||
pub const BLOCKS_PER_HALVING: u32 = 210_000;
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
@@ -78,7 +80,7 @@ impl Add<usize> for HalvingEpoch {
|
||||
|
||||
impl From<Height> for HalvingEpoch {
|
||||
fn from(value: Height) -> Self {
|
||||
Self((u32::from(value) / 210_000) as u16)
|
||||
Self((u32::from(value) / BLOCKS_PER_HALVING) as u16)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use vecdb::{CheckedSub, Printable, Stamp, StoredCompressed};
|
||||
use zerocopy::{FromBytes, IntoBytes};
|
||||
use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use crate::{BLOCKS_PER_DIFF_EPOCHS, copy_first_4bytes};
|
||||
use crate::{BLOCKS_PER_DIFF_EPOCHS, BLOCKS_PER_HALVING, copy_first_4bytes};
|
||||
|
||||
use super::StoredU64;
|
||||
|
||||
@@ -74,7 +74,11 @@ impl Height {
|
||||
}
|
||||
|
||||
pub fn left_before_next_diff_adj(self) -> u32 {
|
||||
BLOCKS_PER_DIFF_EPOCHS - (*self % 2016)
|
||||
BLOCKS_PER_DIFF_EPOCHS - (*self % BLOCKS_PER_DIFF_EPOCHS)
|
||||
}
|
||||
|
||||
pub fn left_before_next_halving(self) -> u32 {
|
||||
BLOCKS_PER_HALVING - (*self % BLOCKS_PER_HALVING)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user