fn random_sync_candidate<T: BlockTree>(
        &self,
        locators: &[BlockHash],
        tree: &T,
    ) -> Option<&PeerState> {
        let candidates = self
            .peers
            .values()
            .filter(|p| self.is_sync_candidate(p, locators, tree));

        if let Some(peers) = NonEmpty::from_vec(candidates.collect()) {
            let ix = self.rng.usize(..peers.len());

            return peers.get(ix).cloned();
        }

        None
    }
/// Pick a random peer we could sync with using the given locators.
Pick a random peer we could sync with using the given locators.
Pick a random peer we could sync with using the given locators .
fn random_sync_candidate<T: BlockTree>(
        &self,
        locators: &[BlockHash],
        tree: &T,
    ) -> Option<&PeerState> {
        let candidates = self
            .peers
            .values()
            .filter(|p| self.is_sync_candidate(p, locators, tree));
        if let Some(peers) = NonEmpty::from_vec(candidates.collect()) {
            let ix = self.rng.usize(..peers.len());
            return peers.get(ix).cloned();
        }
        None
    }
fn random_sync_candidate < T : BlockTree > ( & self , locators : & [ BlockHash ] , tree : & T , ) -> Option < & PeerState > { let candidates = self . peers . values ( ) . filter ( | p | self . is_sync_candidate ( p , locators , tree ) ) ; if let Some ( peers ) = NonEmpty :: from_vec ( candidates . collect ( ) ) { let ix = self . rng . usize ( .. peers . len ( ) ) ; return peers . get ( ix ) . cloned ( ) ; } None }
Pick a random peer we could sync with using the given locators.
Pick a random peer we could sync with using the given locators .
&self
locators
&[BlockHash]
tree
&T