fn check_predecessor_relationship(
        &self,
        tail: &[BlockPair],
        head: &BlockPair,
    ) -> Result<(), BlockManagerError> {
        let mut previous = None;
        for block in tail {
            match previous {
                Some(previous_block_id) => {
                    if block.header().previous_block_id() != previous_block_id {
                        return Err(BlockManagerError::MissingPredecessorInBranch(format!(
                            "During Put, missing predecessor of block {}: {}",
                            block.block().header_signature(),
                            block.header().previous_block_id()
                        )));
                    }
                    previous = Some(block.block().header_signature());
                }
                None => {
                    if block.header().previous_block_id() != head.block().header_signature() {
                        return Err(BlockManagerError::MissingPredecessorInBranch(format!(
                            "During Put, missing predecessor of block {}: {}",
                            block.header().previous_block_id(),
                            head.block().header_signature()
                        )));
                    }

                    previous = Some(block.block().header_signature());
                }
            }
        }
        Ok(())
    }
/// Checks that every block is preceded by the block referenced by block.previous_block_id
/// except the zeroth block in tail, which references head.
Checks that every block is preceded by the block referenced by block.previous_block_id
except the zeroth block in tail, which references head.
Checks that every block is preceded by the block referenced by block . previous_block_id except the zeroth block in tail which references head .
fn check_predecessor_relationship(
        &self,
        tail: &[BlockPair],
        head: &BlockPair,
    ) -> Result<(), BlockManagerError> {
        let mut previous = None;
        for block in tail {
            match previous {
                Some(previous_block_id) => {
                    if block.header().previous_block_id() != previous_block_id {
                        return Err(BlockManagerError::MissingPredecessorInBranch(format!(
                            "During Put, missing predecessor of block {}: {}",
                            block.block().header_signature(),
                            block.header().previous_block_id()
                        )));
                    }
                    previous = Some(block.block().header_signature());
                }
                None => {
                    if block.header().previous_block_id() != head.block().header_signature() {
                        return Err(BlockManagerError::MissingPredecessorInBranch(format!(
                            "During Put, missing predecessor of block {}: {}",
                            block.header().previous_block_id(),
                            head.block().header_signature()
                        )));
                    }
                    previous = Some(block.block().header_signature());
                }
            }
        }
        Ok(())
    }
fn check_predecessor_relationship ( & self , tail : & [ BlockPair ] , head : & BlockPair , ) -> Result < ( ) , BlockManagerError > { let mut previous = None ; for block in tail { match previous { Some ( previous_block_id ) => { if block . header ( ) . previous_block_id ( ) != previous_block_id { return Err ( BlockManagerError :: MissingPredecessorInBranch ( format ! ( " " block block ( ) header_signature ( ) block header ( ) previous_block_id ( ) ) ) ) ; } previous = Some ( block . block ( ) . header_signature ( ) ) ; } None => { if block . header ( ) . previous_block_id ( ) != head . block ( ) . header_signature ( ) { return Err ( BlockManagerError :: MissingPredecessorInBranch ( format ! ( " " block header ( ) previous_block_id ( ) head block ( ) header_signature ( ) ) ) ) ; } previous = Some ( block . block ( ) . header_signature ( ) ) ; } } } Ok ( ( ) ) }
Checks that every block is preceded by the block referenced by block.previous_block_id
except the zeroth block in tail, which references head.
Checks that every block is preceded by the block referenced by block . previous_block_id except the zeroth block in tail which references head .
&self
tail
&[BlockPair]
head
&BlockPair
&self
tail
&[BlockPair]
head
&BlockPair