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§

source

fn initialize(&self) -> Result<(), String>

Wait for initialization.

source

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.

source

fn latest_block(&self) -> PosBlockId

Return the latest committed PoS block ID. This will become the PoS reference of the mined PoW block.

source

fn get_events(&self, from: &PosBlockId, to: &PosBlockId) -> Vec<ContractEvent>

source

fn get_epoch_ending_blocks( &self, start_epoch: u64, end_epoch: u64 ) -> Vec<PosBlockId>

source

fn get_reward_event(&self, epoch: u64) -> Option<RewardDistributionEventV2>

source

fn get_epoch_state(&self, block_id: &PosBlockId) -> EpochState

source

fn pos_ledger_db(&self) -> &Arc<PosLedgerDB>

source

fn consensus_db(&self) -> &Arc<ConsensusDB>

source

fn cached_db(&self) -> &Arc<CachedPosLedgerDB>

Implementors§