global: add mining related datasets

This commit is contained in:
nym21
2025-09-10 21:57:15 +02:00
parent 9b92c5ce38
commit 72bba06e71
7 changed files with 116 additions and 5 deletions
@@ -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)
}
}
+5 -1
View File
@@ -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 {