// Finds the set of sync peers that have the best tip on their main chain and have all the data required to update the
// local node.
Finds the set of sync peers that have the best tip on their main chain and have all the data required to update the
local node.
Finds the set of sync peers that have the best tip on their main chain and have all the data required to update the local node .
fn select_sync_peers(
    local_tip_height: u64,
    best_metadata: &ChainMetadata,
    peer_metadata_list: &[PeerChainMetadata],
) -> Vec<PeerChainMetadata>
{
    peer_metadata_list
        .iter()
        // Metadata sanity checks
        .filter(|p| p.chain_metadata.accumulated_difficulty.is_some() && p.chain_metadata.best_block.is_some())
        // Check if the peer can provide blocks higher than the local tip height
        .filter(|p| {
            let peer_horizon_height = p.chain_metadata.effective_pruned_height;
            local_tip_height >= peer_horizon_height
        })
        // Filter for peers that match the best metadata
        .filter(|p| p.chain_metadata.best_block == best_metadata.best_block)
        .cloned()
        .collect()
}
fn select_sync_peers ( local_tip_height : u64 , best_metadata : & ChainMetadata , peer_metadata_list : & [ PeerChainMetadata ] , ) -> Vec < PeerChainMetadata > { peer_metadata_list . iter ( ) // Metadata sanity checks . filter ( | p | p . chain_metadata . accumulated_difficulty . is_some ( ) && p . chain_metadata . best_block . is_some ( ) ) // Check if the peer can provide blocks higher than the local tip height . filter ( | p | { let peer_horizon_height = p . chain_metadata . effective_pruned_height ; local_tip_height >= peer_horizon_height } ) // Filter for peers that match the best metadata . filter ( | p | p . chain_metadata . best_block == best_metadata . best_block ) . cloned ( ) . collect ( ) }
Finds the set of sync peers that have the best tip on their main chain and have all the data required to update the
local node.
Finds the set of sync peers that have the best tip on their main chain and have all the data required to update the local node .
local_tip_height
u64
best_metadata
&ChainMetadata
peer_metadata_list
&[PeerChainMetadata]