fn best_metadata(metadata_list: &[PeerChainMetadata]) -> ChainMetadata {
    // TODO: Use heuristics to weed out outliers / dishonest nodes.
    metadata_list.iter().fold(ChainMetadata::default(), |best, current| {
        if current.chain_metadata.accumulated_difficulty.unwrap_or_else(|| 0) >=
            best.accumulated_difficulty.unwrap_or_else(|| 0)
        {
            current.chain_metadata.clone()
        } else {
            best
        }
    })
}
/// Determine the best metadata from a set of metadata received from the network.
Determine the best metadata from a set of metadata received from the network.
Determine the best metadata from a set of metadata received from the network .
fn best_metadata(metadata_list: &[PeerChainMetadata]) -> ChainMetadata {
    // TODO: Use heuristics to weed out outliers / dishonest nodes.
    metadata_list.iter().fold(ChainMetadata::default(), |best, current| {
        if current.chain_metadata.accumulated_difficulty.unwrap_or_else(|| 0) >=
            best.accumulated_difficulty.unwrap_or_else(|| 0)
        {
            current.chain_metadata.clone()
        } else {
            best
        }
    })
}
fn best_metadata ( metadata_list : & [ PeerChainMetadata ] ) -> ChainMetadata { // TODO: Use heuristics to weed out outliers / dishonest nodes. metadata_list . iter ( ) . fold ( ChainMetadata :: default ( ) , | best , current | { if current . chain_metadata . accumulated_difficulty . unwrap_or_else ( | | 0 ) >= best . accumulated_difficulty . unwrap_or_else ( | | 0 ) { current . chain_metadata . clone ( ) } else { best } } ) }
Determine the best metadata from a set of metadata received from the network.
Determine the best metadata from a set of metadata received from the network .
metadata_list
&[PeerChainMetadata]
metadata_list
&[PeerChainMetadata]