fn insert_to_deploy_index(
    deploy_hash_index: &mut BTreeMap<DeployHash, BlockHash>,
    block_hash: BlockHash,
    block_body: &BlockBody,
) -> Result<(), Error> {
    if let Some(hash) = block_body
        .deploy_hashes()
        .iter()
        .chain(block_body.transfer_hashes().iter())
        .find(|hash| {
            deploy_hash_index
                .get(hash)
                .map_or(false, |old_block_hash| *old_block_hash != block_hash)
        })
    {
        return Err(Error::DuplicateDeployIndex {
            deploy_hash: *hash,
            first: deploy_hash_index[hash],
            second: block_hash,
        });
    }

    for hash in block_body
        .deploy_hashes()
        .iter()
        .chain(block_body.transfer_hashes().iter())
    {
        deploy_hash_index.insert(*hash, block_hash);
    }

    Ok(())
}
/// Inserts the relevant entries to the index.
///
/// If a duplicate entry is encountered, index is not updated and an error is returned.
Inserts the relevant entries to the index.
If a duplicate entry is encountered, index is not updated and an error is returned.
Inserts the relevant entries to the index . If a duplicate entry is encountered index is not updated and an error is returned .
fn insert_to_deploy_index(
    deploy_hash_index: &mut BTreeMap<DeployHash, BlockHash>,
    block_hash: BlockHash,
    block_body: &BlockBody,
) -> Result<(), Error> {
    if let Some(hash) = block_body
        .deploy_hashes()
        .iter()
        .chain(block_body.transfer_hashes().iter())
        .find(|hash| {
            deploy_hash_index
                .get(hash)
                .map_or(false, |old_block_hash| *old_block_hash != block_hash)
        })
    {
        return Err(Error::DuplicateDeployIndex {
            deploy_hash: *hash,
            first: deploy_hash_index[hash],
            second: block_hash,
        });
    }
    for hash in block_body
        .deploy_hashes()
        .iter()
        .chain(block_body.transfer_hashes().iter())
    {
        deploy_hash_index.insert(*hash, block_hash);
    }
    Ok(())
}
fn insert_to_deploy_index ( deploy_hash_index : & mut BTreeMap < DeployHash , BlockHash > , block_hash : BlockHash , block_body : & BlockBody , ) -> Result < ( ) , Error > { if let Some ( hash ) = block_body . deploy_hashes ( ) . iter ( ) . chain ( block_body . transfer_hashes ( ) . iter ( ) ) . find ( | hash | { deploy_hash_index . get ( hash ) . map_or ( false , | old_block_hash | * old_block_hash != block_hash ) } ) { return Err ( Error :: DuplicateDeployIndex { deploy_hash : * hash , first : deploy_hash_index [ hash ] , second : block_hash , } ) ; } for hash in block_body . deploy_hashes ( ) . iter ( ) . chain ( block_body . transfer_hashes ( ) . iter ( ) ) { deploy_hash_index . insert ( * hash , block_hash ) ; } Ok ( ( ) ) }
Inserts the relevant entries to the index.
Inserts the relevant entries to the index .
deploy_hash_index
&mut BTreeMap<DeployHash, BlockHash>
block_hash
BlockHash
block_body
&BlockBody
deploy_hash_index
&mut BTreeMap<DeployHash, BlockHash>
block_hash
BlockHash
block_body
&BlockBody