fn verify_ancestry<Header>(
        proof: Vec<Header>,
        ancestor_hash: Header::Hash,
        child: &Header,
    ) -> Result<(), Error>
    where
        Header: HeaderT,
    {
        let mut parent_hash = child.parent_hash();
        if *parent_hash == ancestor_hash {
            return Ok(());
        }

        // If we find that the header's parent hash matches our ancestor's hash we're done
        for header in proof.iter() {
            // Need to check that blocks are actually related
            if header.hash() != *parent_hash {
                break;
            }

            parent_hash = header.parent_hash();
            if *parent_hash == ancestor_hash {
                return Ok(());
            }
        }

        Err(Error::InvalidAncestryProof)
    }
// A naive way to check whether a `child` header is a decendent
// of an `ancestor` header. For this it requires a proof which
// is a chain of headers between (but not including) the `child`
// and `ancestor`. This could be updated to use something like
// Log2 Ancestors (#2053) in the future.
A naive way to check whether a `child` header is a decendent
of an `ancestor` header. For this it requires a proof which
is a chain of headers between (but not including) the `child`
and `ancestor`. This could be updated to use something like
Log2 Ancestors (#2053) in the future.
A naive way to check whether a ` child ` header is a decendent of an ` ancestor ` header . For this it requires a proof which is a chain of headers between ( but not including ) the ` child ` and ` ancestor ` . This could be updated to use something like Log2 Ancestors ( #2053 ) in the future .
fn verify_ancestry<Header>(
        proof: Vec<Header>,
        ancestor_hash: Header::Hash,
        child: &Header,
    ) -> Result<(), Error>
    where
        Header: HeaderT,
    {
        let mut parent_hash = child.parent_hash();
        if *parent_hash == ancestor_hash {
            return Ok(());
        }
        // If we find that the header's parent hash matches our ancestor's hash we're done
        for header in proof.iter() {
            // Need to check that blocks are actually related
            if header.hash() != *parent_hash {
                break;
            }
            parent_hash = header.parent_hash();
            if *parent_hash == ancestor_hash {
                return Ok(());
            }
        }
        Err(Error::InvalidAncestryProof)
    }
fn verify_ancestry < Header > ( proof : Vec < Header > , ancestor_hash : Header :: Hash , child : & Header , ) -> Result < ( ) , Error > where Header : HeaderT , { let mut parent_hash = child . parent_hash ( ) ; if * parent_hash == ancestor_hash { return Ok ( ( ) ) ; } // If we find that the header's parent hash matches our ancestor's hash we're done for header in proof . iter ( ) { // Need to check that blocks are actually related if header . hash ( ) != * parent_hash { break ; } parent_hash = header . parent_hash ( ) ; if * parent_hash == ancestor_hash { return Ok ( ( ) ) ; } } Err ( Error :: InvalidAncestryProof ) }
A naive way to check whether a `child` header is a decendent
of an `ancestor` header.
A naive way to check whether a ` child ` header is a decendent of an ` ancestor ` header .
proof
Vec<Header>
ancestor_hash
Header::Hash
child
&Header
proof
Vec<Header>
ancestor_hash
Header::Hash
child
&Header