fn sample_peer(&mut self) -> Option<PeerId> {
        let num_peers = self.connected_peers.len();
        if num_peers > 0 {
            // The particular index is not important, just the probability of
            // sampling any of the current peers is equal.
            let idx = self.rng.gen_range(0, num_peers);
            self.connected_peers.iter().nth(idx).copied()
        } else {
            None
        }
    }
/// Sample iid a PeerId of one of the connected peers.
Sample iid a PeerId of one of the connected peers.
Sample iid a PeerId of one of the connected peers .
fn sample_peer(&mut self) -> Option<PeerId> {
        let num_peers = self.connected_peers.len();
        if num_peers > 0 {
            // The particular index is not important, just the probability of
            // sampling any of the current peers is equal.
            let idx = self.rng.gen_range(0, num_peers);
            self.connected_peers.iter().nth(idx).copied()
        } else {
            None
        }
    }
fn sample_peer ( & mut self ) -> Option < PeerId > { let num_peers = self . connected_peers . len ( ) ; if num_peers > 0 { // The particular index is not important, just the probability of // sampling any of the current peers is equal. let idx = self . rng . gen_range ( 0 , num_peers ) ; self . connected_peers . iter ( ) . nth ( idx ) . copied ( ) } else { None } }
Sample iid a PeerId of one of the connected peers.
Sample iid a PeerId of one of the connected peers .
&mut self
&mut self