mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-11 19:18:14 -07:00
global: add mining 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_DIFF_EPOCHS: u32 = 2016;
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
@@ -79,7 +81,7 @@ impl Div<usize> for DifficultyEpoch {
|
||||
|
||||
impl From<Height> for DifficultyEpoch {
|
||||
fn from(value: Height) -> Self {
|
||||
Self((u32::from(value) / 2016) as u16)
|
||||
Self((u32::from(value) / BLOCKS_PER_DIFF_EPOCHS) 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::copy_first_4bytes;
|
||||
use crate::{BLOCKS_PER_DIFF_EPOCHS, copy_first_4bytes};
|
||||
|
||||
use super::StoredU64;
|
||||
|
||||
@@ -72,6 +72,10 @@ impl Height {
|
||||
pub fn is_not_zero(self) -> bool {
|
||||
self != Self::ZERO
|
||||
}
|
||||
|
||||
pub fn left_before_next_diff_adj(self) -> u32 {
|
||||
BLOCKS_PER_DIFF_EPOCHS - (*self % 2016)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<u64> for Height {
|
||||
|
||||
Reference in New Issue
Block a user