mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 22:59:58 -07:00
21 lines
427 B
Rust
21 lines
427 B
Rust
use super::{Height, MapKey};
|
|
|
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
|
|
pub struct Epoch(pub u16);
|
|
|
|
impl Epoch {
|
|
pub const BLOCKS_PER_EPOCH: usize = 210_000;
|
|
}
|
|
|
|
impl From<Height> for Epoch {
|
|
fn from(height: Height) -> Self {
|
|
Self::from(&height)
|
|
}
|
|
}
|
|
|
|
impl From<&Height> for Epoch {
|
|
fn from(height: &Height) -> Self {
|
|
Self(((height.to_usize() / Self::BLOCKS_PER_EPOCH) + 1) as u16)
|
|
}
|
|
}
|