pub trait ProtocolController: Send + Sync {
// Required methods
fn stop(&mut self);
fn integrated_block(
&self,
block_id: BlockId,
storage: Storage,
) -> Result<(), ProtocolError>;
fn notify_block_attack(
&self,
block_id: BlockId,
) -> Result<(), ProtocolError>;
fn send_wishlist_delta(
&self,
new: PreHashMap<BlockId, Option<SecuredHeader>>,
remove: PreHashSet<BlockId>,
) -> Result<(), ProtocolError>;
fn propagate_operations(
&self,
operations: Storage,
) -> Result<(), ProtocolError>;
fn propagate_endorsements(
&self,
endorsements: Storage,
) -> Result<(), ProtocolError>;
fn get_stats(
&self,
) -> Result<(NetworkStats, HashMap<PeerId, (SocketAddr, PeerConnectionType)>), ProtocolError>;
fn get_bootstrap_peers(&self) -> Result<BootstrapPeers, ProtocolError>;
fn ban_peers(&self, peer_ids: Vec<PeerId>) -> Result<(), ProtocolError>;
fn unban_peers(&self, peer_ids: Vec<PeerId>) -> Result<(), ProtocolError>;
fn clone_box(&self) -> Box<dyn ProtocolController>;
}
Required Methods§
sourcefn stop(&mut self)
fn stop(&mut self)
Perform all operations needed to stop the ProtocolController without dropping it completely yet.
sourcefn integrated_block(
&self,
block_id: BlockId,
storage: Storage,
) -> Result<(), ProtocolError>
fn integrated_block( &self, block_id: BlockId, storage: Storage, ) -> Result<(), ProtocolError>
Sends the order to propagate the header of a block
§Arguments
block_id
: ID of the blockstorage
: Storage instance containing references to the block and all its dependencies
sourcefn notify_block_attack(&self, block_id: BlockId) -> Result<(), ProtocolError>
fn notify_block_attack(&self, block_id: BlockId) -> Result<(), ProtocolError>
sourcefn send_wishlist_delta(
&self,
new: PreHashMap<BlockId, Option<SecuredHeader>>,
remove: PreHashSet<BlockId>,
) -> Result<(), ProtocolError>
fn send_wishlist_delta( &self, new: PreHashMap<BlockId, Option<SecuredHeader>>, remove: PreHashSet<BlockId>, ) -> Result<(), ProtocolError>
Update the block wish list
§Arguments
new
: new blocks to add to the wish listremove
: blocks to remove from the wish list
sourcefn propagate_operations(&self, operations: Storage) -> Result<(), ProtocolError>
fn propagate_operations(&self, operations: Storage) -> Result<(), ProtocolError>
Propagate a batch of operation (from pool).
note: Full OperationId
is replaced by a OperationPrefixId
later by the worker.
§Arguments:
operations
: operations to propagate
sourcefn propagate_endorsements(
&self,
endorsements: Storage,
) -> Result<(), ProtocolError>
fn propagate_endorsements( &self, endorsements: Storage, ) -> Result<(), ProtocolError>
sourcefn get_stats(
&self,
) -> Result<(NetworkStats, HashMap<PeerId, (SocketAddr, PeerConnectionType)>), ProtocolError>
fn get_stats( &self, ) -> Result<(NetworkStats, HashMap<PeerId, (SocketAddr, PeerConnectionType)>), ProtocolError>
Get the stats from the protocol Returns a tuple containing the stats and the list of peers
sourcefn get_bootstrap_peers(&self) -> Result<BootstrapPeers, ProtocolError>
fn get_bootstrap_peers(&self) -> Result<BootstrapPeers, ProtocolError>
Get a list of peers to be sent to someone that bootstrap to us
sourcefn unban_peers(&self, peer_ids: Vec<PeerId>) -> Result<(), ProtocolError>
fn unban_peers(&self, peer_ids: Vec<PeerId>) -> Result<(), ProtocolError>
Unban a list of Peer Id
sourcefn clone_box(&self) -> Box<dyn ProtocolController>
fn clone_box(&self) -> Box<dyn ProtocolController>
Returns a boxed clone of self.
Useful to allow cloning Box<dyn ProtocolController>
.
Trait Implementations§
source§impl Clone for Box<dyn ProtocolController>
impl Clone for Box<dyn ProtocolController>
Allow cloning Box<dyn ProtocolController>
Uses ProtocolController::clone_box
internally