/// Adds a new peer to the base node
/// ## Parameters
/// `comms_node` - A reference to the comms node. This is the communications stack
/// `peers` - A list of peers to be added to the comms node, the current node identity of the comms stack is excluded if
/// found in the list.
///
/// ## Returns
/// A Result to determine if the call was successful or not, string will indicate the reason on error
Adds a new peer to the base node
Adds a new peer to the base node
async fn add_all_peers(
    peer_manager: &PeerManager,
    node_identity: &NodeIdentity,
    peers: Vec<Peer>,
) -> Result<(), CommsInitializationError>
{
    for peer in peers {
        let peer_desc = peer.to_string();
        debug!(target: LOG_TARGET, "Adding seed peer [{}]", peer);
        if &peer.public_key == node_identity.public_key() {
            debug!(
                target: LOG_TARGET,
                "Attempting to add yourself [{}] as a seed peer to comms layer, ignoring request", peer_desc
            );
            continue;
        }
        peer_manager
            .add_peer(peer)
            .await
            .map_err(CommsInitializationError::FailedToAddSeedPeer)?;
    }
    Ok(())
}
async fn add_all_peers ( peer_manager : & PeerManager , node_identity : & NodeIdentity , peers : Vec < Peer > , ) -> Result < ( ) , CommsInitializationError > { for peer in peers { let peer_desc = peer . to_string ( ) ; debug ! ( target LOG_TARGET " " peer ) ; if & peer . public_key == node_identity . public_key ( ) { debug ! ( target LOG_TARGET " " peer_desc ) ; continue ; } peer_manager . add_peer ( peer ) . await . map_err ( CommsInitializationError :: FailedToAddSeedPeer ) ? ; } Ok ( ( ) ) }
Adds a new peer to the base node
Adds a new peer to the base node
A Result to determine if the call was successful or not, string will indicate the reason on error
A Result to determine if the call was successful or not string will indicate the reason on error
peer_manager
&PeerManager
node_identity
&NodeIdentity
peers
Vec<Peer>