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§
sourcefn get_block_graph_status(
&self,
start_slot: Option<Slot>,
end_slot: Option<Slot>,
) -> Result<BlockGraphExport, ConsensusError>
fn get_block_graph_status( &self, start_slot: Option<Slot>, end_slot: Option<Slot>, ) -> Result<BlockGraphExport, ConsensusError>
sourcefn get_block_statuses(&self, ids: &[BlockId]) -> Vec<BlockGraphStatus>
fn get_block_statuses(&self, ids: &[BlockId]) -> Vec<BlockGraphStatus>
sourcefn get_cliques(&self) -> Vec<Clique>
fn get_cliques(&self) -> Vec<Clique>
sourcefn get_bootstrap_part(
&self,
cursor: StreamingStep<PreHashSet<BlockId>>,
execution_cursor: StreamingStep<Slot>,
) -> Result<(BootstrapableGraph, PreHashSet<BlockId>, StreamingStep<PreHashSet<BlockId>>), ConsensusError>
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 clientexecution_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
sourcefn get_stats(&self) -> Result<ConsensusStats, ConsensusError>
fn get_stats(&self) -> Result<ConsensusStats, ConsensusError>
sourcefn get_best_parents(&self) -> Vec<(BlockId, u64)>
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
sourcefn get_blockclique_block_at_slot(&self, slot: Slot) -> Option<BlockId>
fn get_blockclique_block_at_slot(&self, slot: Slot) -> Option<BlockId>
sourcefn get_latest_blockclique_block_at_slot(&self, slot: Slot) -> BlockId
fn get_latest_blockclique_block_at_slot(&self, slot: Slot) -> BlockId
sourcefn register_block(
&self,
block_id: BlockId,
slot: Slot,
block_storage: Storage,
created: bool,
)
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 registerslot: the slot of the blockblock_storage: the storage that contains all the objects of the blockcreated: is the block created by our node ?
sourcefn register_block_header(
&self,
block_id: BlockId,
header: SecureShare<BlockHeader, BlockId>,
)
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 registerheader: the header of the block to register
sourcefn mark_invalid_block(
&self,
block_id: BlockId,
header: SecureShare<BlockHeader, BlockId>,
)
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 invalidheader: the header of the block to mark as invalid
sourcefn clone_box(&self) -> Box<dyn ConsensusController>
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>
impl Clone for Box<dyn ConsensusController>
Allow cloning Box<dyn ConsensusController>
Uses ConsensusController::clone_box internally