pub fn add_peers(&mut self, new_peers: Vec<Peer>) -> Result<(), Error> {
        let peers = match &mut self.contents {
            Contents::V1 { ref mut peers, .. } => peers,
        };

        for new_peer in new_peers {
            if let Some(existing_peer) = peers.iter_mut().find(|p| p.ip == new_peer.ip) {
                if existing_peer.public_key != new_peer.public_key {
                    return Err(
                        "PINNING ERROR: New peer has same IP but different public key.".into(),
                    );
                } else {
                    *existing_peer = new_peer;
                }
            } else {
                peers.push(new_peer);
            }
        }

        Ok(())
    }
/// Add new peers to the PeerStore, never deleting old ones.
///
/// This is done as a protective measure, validating that the (IP, PublicKey) tuple
/// of the interface's peers never change, i.e. "pinning" them. This prevents a compromised
/// server from impersonating an existing peer.
///
/// Note, however, that this does not prevent a compromised server from adding a new
/// peer under its control, of course.
Add new peers to the PeerStore, never deleting old ones.
This is done as a protective measure, validating that the (IP, PublicKey) tuple
of the interface's peers never change, i.e. "pinning" them. This prevents a compromised
server from impersonating an existing peer.

Note, however, that this does not prevent a compromised server from adding a new
peer under its control, of course.
Add new peers to the PeerStore never deleting old ones . This is done as a protective measure validating that the ( IP PublicKey ) tuple of the interface ' s peers never change i . e . " pinning " them . This prevents a compromised server from impersonating an existing peer . Note however that this does not prevent a compromised server from adding a new peer under its control of course .
pub fn add_peers(&mut self, new_peers: Vec<Peer>) -> Result<(), Error> {
        let peers = match &mut self.contents {
            Contents::V1 { ref mut peers, .. } => peers,
        };
        for new_peer in new_peers {
            if let Some(existing_peer) = peers.iter_mut().find(|p| p.ip == new_peer.ip) {
                if existing_peer.public_key != new_peer.public_key {
                    return Err(
                        "PINNING ERROR: New peer has same IP but different public key.".into(),
                    );
                } else {
                    *existing_peer = new_peer;
                }
            } else {
                peers.push(new_peer);
            }
        }
        Ok(())
    }
pub fn add_peers ( & mut self , new_peers : Vec < Peer > ) -> Result < ( ) , Error > { let peers = match & mut self . contents { Contents :: V1 { ref mut peers , .. } => peers , } ; for new_peer in new_peers { if let Some ( existing_peer ) = peers . iter_mut ( ) . find ( | p | p . ip == new_peer . ip ) { if existing_peer . public_key != new_peer . public_key { return Err ( " " . into ( ) , ) ; } else { * existing_peer = new_peer ; } } else { peers . push ( new_peer ) ; } } Ok ( ( ) ) }
Add new peers to the PeerStore, never deleting old ones.
Add new peers to the PeerStore never deleting old ones .
&mut self
new_peers
Vec<Peer>
&mut self
new_peers
Vec<Peer>