Trait cfxcore::consensus::pos_handler::PosInterface
source · pub trait PosInterface: Send + Sync {
// Required methods
fn initialize(&self) -> Result<(), String>;
fn get_committed_block(&self, h: &PosBlockId) -> Option<PosBlock>;
fn latest_block(&self) -> PosBlockId;
fn get_events(
&self,
from: &PosBlockId,
to: &PosBlockId
) -> Vec<ContractEvent>;
fn get_epoch_ending_blocks(
&self,
start_epoch: u64,
end_epoch: u64
) -> Vec<PosBlockId>;
fn get_reward_event(&self, epoch: u64) -> Option<RewardDistributionEventV2>;
fn get_epoch_state(&self, block_id: &PosBlockId) -> EpochState;
fn pos_ledger_db(&self) -> &Arc<PosLedgerDB>;
fn consensus_db(&self) -> &Arc<ConsensusDB>;
fn cached_db(&self) -> &Arc<CachedPosLedgerDB>;
}
Expand description
This includes the interfaces that the PoW consensus needs from the PoS consensus.
We assume the PoS service will be always available after initialize()
returns, so all the other interfaces will panic if the PoS service is not
ready.
Required Methods§
sourcefn initialize(&self) -> Result<(), String>
fn initialize(&self) -> Result<(), String>
Wait for initialization.
sourcefn get_committed_block(&self, h: &PosBlockId) -> Option<PosBlock>
fn get_committed_block(&self, h: &PosBlockId) -> Option<PosBlock>
Get a PoS block by its ID.
Return None
if the block does not exist or is not committed.
sourcefn latest_block(&self) -> PosBlockId
fn latest_block(&self) -> PosBlockId
Return the latest committed PoS block ID. This will become the PoS reference of the mined PoW block.