pub trait ConsensusController: Send + Sync {
    // Required methods
    fn get_block_graph_status(
        &self,
        start_slot: Option<Slot>,
        end_slot: Option<Slot>,
    ) -> Result<BlockGraphExport, ConsensusError>;
    fn get_block_statuses(&self, ids: &[BlockId]) -> Vec<BlockGraphStatus>;
    fn get_cliques(&self) -> Vec<Clique>;
    fn get_bootstrap_part(
        &self,
        cursor: StreamingStep<PreHashSet<BlockId>>,
        execution_cursor: StreamingStep<Slot>,
    ) -> Result<(BootstrapableGraph, PreHashSet<BlockId>, StreamingStep<PreHashSet<BlockId>>), ConsensusError>;
    fn get_stats(&self) -> Result<ConsensusStats, ConsensusError>;
    fn get_best_parents(&self) -> Vec<(BlockId, u64)>;
    fn get_blockclique_block_at_slot(&self, slot: Slot) -> Option<BlockId>;
    fn get_latest_blockclique_block_at_slot(&self, slot: Slot) -> BlockId;
    fn register_block(
        &self,
        block_id: BlockId,
        slot: Slot,
        block_storage: Storage,
        created: bool,
    );
    fn register_block_header(
        &self,
        block_id: BlockId,
        header: SecureShare<BlockHeader, BlockId>,
    );
    fn mark_invalid_block(
        &self,
        block_id: BlockId,
        header: SecureShare<BlockHeader, BlockId>,
    );
    fn clone_box(&self) -> Box<dyn ConsensusController>;
}
Expand description

Interface that communicates with the graph worker thread

Required Methods§

source

fn get_block_graph_status( &self, start_slot: Option<Slot>, end_slot: Option<Slot>, ) -> Result<BlockGraphExport, ConsensusError>

Get an export of a part of the graph

§Arguments
  • start_slot: the slot to start the export from, if None, the export starts from the genesis
  • end_slot: the slot to end the export at, if None, the export ends at the current slot
§Returns

The export of the graph

source

fn get_block_statuses(&self, ids: &[BlockId]) -> Vec<BlockGraphStatus>

Get statuses of a list of blocks

§Arguments
  • ids: the list of block ids to get the status of
§Returns

The statuses of the blocks sorted by the order of the input list

source

fn get_cliques(&self) -> Vec<Clique>

Get all the cliques of the graph

§Returns

The list of cliques

source

fn get_bootstrap_part( &self, cursor: StreamingStep<PreHashSet<BlockId>>, execution_cursor: StreamingStep<Slot>, ) -> Result<(BootstrapableGraph, PreHashSet<BlockId>, StreamingStep<PreHashSet<BlockId>>), ConsensusError>

Get a part of the graph to send to a node for it to setup its graph. Used for bootstrap.

§Arguments:
  • cursor: streaming cursor containing the current state of bootstrap and what blocks have previously been sent to the client
  • execution_cursor: streaming cursor of the final state to ensure that last slot of the bootstrap info match the slot of the execution
§Returns:
  • A portion of the graph
  • The list of outdated block ids
  • The streaming step value after the current iteration to be saved to be able to use it as parameters and resume the bootstrap
source

fn get_stats(&self) -> Result<ConsensusStats, ConsensusError>

Get the stats of the consensus

§Returns

The stats of the consensus

source

fn get_best_parents(&self) -> Vec<(BlockId, u64)>

Get the best parents for the next block to be produced

§Returns

The id of best parents for the next block to be produced along with their period

source

fn get_blockclique_block_at_slot(&self, slot: Slot) -> Option<BlockId>

Get the block id of the block at a specific slot in the blockclique

§Arguments
  • slot: the slot to get the block id of
§Returns

The block id of the block at the specified slot if exists

source

fn get_latest_blockclique_block_at_slot(&self, slot: Slot) -> BlockId

Get the latest block, that is in the blockclique, in the thread of the given slot and before this slot.

§Arguments:
  • slot: the slot that will give us the thread and the upper bound
§Returns:

The block id of the latest block in the thread of the given slot and before this slot

source

fn register_block( &self, block_id: BlockId, slot: Slot, block_storage: Storage, created: bool, )

Register a block in the graph

§Arguments
  • block_id: the id of the block to register
  • slot: the slot of the block
  • block_storage: the storage that contains all the objects of the block
  • created: is the block created by our node ?
source

fn register_block_header( &self, block_id: BlockId, header: SecureShare<BlockHeader, BlockId>, )

Register a block header in the graph

§Arguments
  • block_id: the id of the block to register
  • header: the header of the block to register
source

fn mark_invalid_block( &self, block_id: BlockId, header: SecureShare<BlockHeader, BlockId>, )

Mark a block as invalid in the graph

§Arguments
  • block_id: the id of the block to mark as invalid
  • header: the header of the block to mark as invalid
source

fn clone_box(&self) -> Box<dyn ConsensusController>

Returns a boxed clone of self. Useful to allow cloning Box<dyn ConsensusController>.

Trait Implementations§

source§

impl Clone for Box<dyn ConsensusController>

Allow cloning Box<dyn ConsensusController> Uses ConsensusController::clone_box internally

source§

fn clone(&self) -> Box<dyn ConsensusController>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§