pub(crate) fn from_list(
        list: impl IntoIterator<Item = (block::Height, block::Hash)>,
    ) -> Result<Self, BoxError> {
        // BTreeMap silently ignores duplicates, so we count the checkpoints
        // before adding them to the map
        let original_checkpoints: Vec<(block::Height, block::Hash)> = list.into_iter().collect();
        let original_len = original_checkpoints.len();

        let checkpoints: BTreeMap<block::Height, block::Hash> =
            original_checkpoints.into_iter().collect();

        // Check that the list starts with the correct genesis block
        match checkpoints.iter().next() {
            Some((block::Height(0), hash))
                if (hash == &genesis_hash(Network::Mainnet)
                    || hash == &genesis_hash(Network::Testnet)) => {}
            Some((block::Height(0), _)) => {
                Err("the genesis checkpoint does not match the Mainnet or Testnet genesis hash")?
            }
            Some(_) => Err("checkpoints must start at the genesis block height 0")?,
            None => Err("there must be at least one checkpoint, for the genesis block")?,
        };

        // This check rejects duplicate heights, whether they have the same or
        // different hashes
        if checkpoints.len() != original_len {
            Err("checkpoint heights must be unique")?;
        }

        let block_hashes: HashSet<&block::Hash> = checkpoints.values().collect();
        if block_hashes.len() != original_len {
            Err("checkpoint hashes must be unique")?;
        }

        // Make sure all the hashes are valid. In Bitcoin, [0; 32] is the null
        // hash. It is also used as the parent hash of genesis blocks.
        if block_hashes.contains(&block::Hash([0; 32])) {
            Err("checkpoint list contains invalid checkpoint hash: found null hash")?;
        }

        let checkpoints = CheckpointList(checkpoints);
        if checkpoints.max_height() > block::Height::MAX {
            Err("checkpoint list contains invalid checkpoint: checkpoint height is greater than the maximum block height")?;
        }

        Ok(checkpoints)
    }
/// Create a new checkpoint list for `network` from `checkpoint_list`.
///
/// Assumes that the provided genesis checkpoint is correct.
///
/// Checkpoint heights and checkpoint hashes must be unique.
/// There must be a checkpoint for a genesis block at block::Height 0.
/// (All other checkpoints are optional.)
Create a new checkpoint list for `network` from `checkpoint_list`.
Assumes that the provided genesis checkpoint is correct.

Checkpoint heights and checkpoint hashes must be unique.
There must be a checkpoint for a genesis block at block::Height 0.
(All other checkpoints are optional.)
Create a new checkpoint list for ` network ` from ` checkpoint_list ` . Assumes that the provided genesis checkpoint is correct . Checkpoint heights and checkpoint hashes must be unique . There must be a checkpoint for a genesis block at block :: Height 0 . ( All other checkpoints are optional . )
pub(crate) fn from_list(
        list: impl IntoIterator<Item = (block::Height, block::Hash)>,
    ) -> Result<Self, BoxError> {
        // BTreeMap silently ignores duplicates, so we count the checkpoints
        // before adding them to the map
        let original_checkpoints: Vec<(block::Height, block::Hash)> = list.into_iter().collect();
        let original_len = original_checkpoints.len();
        let checkpoints: BTreeMap<block::Height, block::Hash> =
            original_checkpoints.into_iter().collect();
        // Check that the list starts with the correct genesis block
        match checkpoints.iter().next() {
            Some((block::Height(0), hash))
                if (hash == &genesis_hash(Network::Mainnet)
                    || hash == &genesis_hash(Network::Testnet)) => {}
            Some((block::Height(0), _)) => {
                Err("the genesis checkpoint does not match the Mainnet or Testnet genesis hash")?
            }
            Some(_) => Err("checkpoints must start at the genesis block height 0")?,
            None => Err("there must be at least one checkpoint, for the genesis block")?,
        };
        // This check rejects duplicate heights, whether they have the same or
        // different hashes
        if checkpoints.len() != original_len {
            Err("checkpoint heights must be unique")?;
        }
        let block_hashes: HashSet<&block::Hash> = checkpoints.values().collect();
        if block_hashes.len() != original_len {
            Err("checkpoint hashes must be unique")?;
        }
        // Make sure all the hashes are valid. In Bitcoin, [0; 32] is the null
        // hash. It is also used as the parent hash of genesis blocks.
        if block_hashes.contains(&block::Hash([0; 32])) {
            Err("checkpoint list contains invalid checkpoint hash: found null hash")?;
        }
        let checkpoints = CheckpointList(checkpoints);
        if checkpoints.max_height() > block::Height::MAX {
            Err("checkpoint list contains invalid checkpoint: checkpoint height is greater than the maximum block height")?;
        }
        Ok(checkpoints)
    }
pub ( crate ) fn from_list ( list : impl IntoIterator < Item = ( block :: Height , block :: Hash ) > , ) -> Result < Self , BoxError > { // BTreeMap silently ignores duplicates, so we count the checkpoints // before adding them to the map let original_checkpoints : Vec < ( block :: Height , block :: Hash ) > = list . into_iter ( ) . collect ( ) ; let original_len = original_checkpoints . len ( ) ; let checkpoints : BTreeMap < block :: Height , block :: Hash > = original_checkpoints . into_iter ( ) . collect ( ) ; // Check that the list starts with the correct genesis block match checkpoints . iter ( ) . next ( ) { Some ( ( block :: Height ( 0 ) , hash ) ) if ( hash == & genesis_hash ( Network :: Mainnet ) || hash == & genesis_hash ( Network :: Testnet ) ) => { } Some ( ( block :: Height ( 0 ) , _ ) ) => { Err ( " " ) ? } Some ( _ ) => Err ( " " ) ? , None => Err ( " " ) ? , } ; // This check rejects duplicate heights, whether they have the same or // different hashes if checkpoints . len ( ) != original_len { Err ( " " ) ? ; } let block_hashes : HashSet < & block :: Hash > = checkpoints . values ( ) . collect ( ) ; if block_hashes . len ( ) != original_len { Err ( " " ) ? ; } // Make sure all the hashes are valid. In Bitcoin, [0; 32] is the null // hash. It is also used as the parent hash of genesis blocks. if block_hashes . contains ( & block :: Hash ( [ 0 ; 32 ] ) ) { Err ( " " ) ? ; } let checkpoints = CheckpointList ( checkpoints ) ; if checkpoints . max_height ( ) > block :: Height :: MAX { Err ( " " ) ? ; } Ok ( checkpoints ) }
Create a new checkpoint list for `network` from `checkpoint_list`.
Create a new checkpoint list for ` network ` from ` checkpoint_list ` .
list
impl IntoIterator<Item = (block::Height, block::Hash)>