primitives/
epoch.rs

1// Copyright 2019 Conflux Foundation. All rights reserved.
2// Conflux is free software and distributed under GNU General Public License.
3// See http://www.gnu.org/licenses/
4
5use cfx_types::H256;
6use keccak_hash::KECCAK_EMPTY;
7use serde_derive::{Deserialize, Serialize};
8
9pub type EpochId = H256;
10pub const NULL_EPOCH: EpochId = KECCAK_EMPTY;
11
12/// Uniquely identifies epoch.
13#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
14pub enum EpochNumber {
15    /// Epoch number within canon blockchain.
16    Number(u64),
17    /// Earliest block (checkpoint).
18    Earliest,
19    /// The latest checkpoint (cur_era_genesis)
20    LatestCheckpoint,
21    /// The latest finalized (confirmed by PoS) block
22    LatestFinalized,
23    /// The latest confirmed block (based on the estimation of the confirmation
24    /// meter)
25    LatestConfirmed,
26    /// Latest block with state.
27    LatestState,
28    /// Latest mined block.
29    LatestMined,
30}
31
32impl Into<EpochNumber> for u64 {
33    fn into(self) -> EpochNumber { EpochNumber::Number(self) }
34}
35
36#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
37pub enum BlockHashOrEpochNumber {
38    BlockHashWithOption {
39        hash: H256,
40        require_pivot: Option<bool>,
41    },
42    EpochNumber(EpochNumber),
43}