fn validate_branch(&self, candidate: &Candidate, clock: &impl Clock) -> Result<(), Error> {
        let fork_header = self
            .get_block_by_height(candidate.fork_height)
            .expect("the given candidate must fork from a known block");
        let mut tip = CachedBlock {
            height: candidate.fork_height,
            hash: candidate.fork_hash,
            header: *fork_header,
        };

        for header in candidate.headers.iter() {
            self.validate(&tip, header, clock)?;

            tip = CachedBlock {
                height: tip.height + 1,
                hash: header.block_hash(),
                header: *header,
            };
        }
        Ok(())
    }
/// Validate a candidate branch. This function is useful for chain selection.
Validate a candidate branch. This function is useful for chain selection.
Validate a candidate branch . This function is useful for chain selection .
fn validate_branch(&self, candidate: &Candidate, clock: &impl Clock) -> Result<(), Error> {
        let fork_header = self
            .get_block_by_height(candidate.fork_height)
            .expect("the given candidate must fork from a known block");
        let mut tip = CachedBlock {
            height: candidate.fork_height,
            hash: candidate.fork_hash,
            header: *fork_header,
        };
        for header in candidate.headers.iter() {
            self.validate(&tip, header, clock)?;
            tip = CachedBlock {
                height: tip.height + 1,
                hash: header.block_hash(),
                header: *header,
            };
        }
        Ok(())
    }
fn validate_branch ( & self , candidate : & Candidate , clock : & impl Clock ) -> Result < ( ) , Error > { let fork_header = self . get_block_by_height ( candidate . fork_height ) . expect ( " " ) ; let mut tip = CachedBlock { height : candidate . fork_height , hash : candidate . fork_hash , header : * fork_header , } ; for header in candidate . headers . iter ( ) { self . validate ( & tip , header , clock ) ? ; tip = CachedBlock { height : tip . height + 1 , hash : header . block_hash ( ) , header : * header , } ; } Ok ( ( ) ) }
Validate a candidate branch.
Validate a candidate branch .
&self
candidate
&Candidate
clock
&impl Clock