Trait massa_protocol_exports::ProtocolController

source ·
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§

source

fn stop(&mut self)

Perform all operations needed to stop the ProtocolController without dropping it completely yet.

source

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 block
  • storage: Storage instance containing references to the block and all its dependencies
source

fn notify_block_attack(&self, block_id: BlockId) -> Result<(), ProtocolError>

Notify to protocol an attack attempt.

§Arguments
  • block_id: ID of the block
source

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 list
  • remove: blocks to remove from the wish list
source

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
source

fn propagate_endorsements( &self, endorsements: Storage, ) -> Result<(), ProtocolError>

Propagate a batch of endorsement (from pool).

§Arguments:
  • endorsements: endorsements to propagate
source

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

source

fn get_bootstrap_peers(&self) -> Result<BootstrapPeers, ProtocolError>

Get a list of peers to be sent to someone that bootstrap to us

source

fn ban_peers(&self, peer_ids: Vec<PeerId>) -> Result<(), ProtocolError>

Ban a list of Peer Id

source

fn unban_peers(&self, peer_ids: Vec<PeerId>) -> Result<(), ProtocolError>

Unban a list of Peer Id

source

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>

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

source§

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

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§