axos_primitives/
blocks.rs

1use alloy_primitives::B256;
2use serde::{Deserialize, Serialize};
3
4/// Block Header Info
5#[derive(Debug, Clone, Copy, Eq, PartialEq, Default, Serialize, Deserialize)]
6pub struct BlockInfo {
7    /// The block hash
8    pub hash: B256,
9    /// The block number
10    pub number: u64,
11    /// The parent block hash
12    pub parent_hash: B256,
13    /// The block timestamp
14    pub timestamp: u64,
15}
16
17impl BlockInfo {
18    /// Instantiates a new [BlockInfo].
19    pub fn new(hash: B256, number: u64, parent_hash: B256, timestamp: u64) -> Self {
20        Self {
21            hash,
22            number,
23            parent_hash,
24            timestamp,
25        }
26    }
27}
28
29/// L1 epoch block
30#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
31pub struct Epoch {
32    /// The block number
33    pub number: u64,
34    /// The block hash
35    pub hash: B256,
36    /// The block timestamp
37    pub timestamp: u64,
38}
39
40impl Epoch {
41    /// Create a new [Epoch].
42    pub fn new(number: u64, hash: B256, timestamp: u64) -> Self {
43        Self {
44            number,
45            hash,
46            timestamp,
47        }
48    }
49}