fn verify(&self) -> Result<(), Label> {
        // Leaf nodes store a hash supplied by the user and are always valid.
        if self.is_leaf() {
            return Ok(());
        }

        let mut hasher = Sha256::new();
        for child in self.children.iter() {
            hasher.update(child.hash.as_ref().unwrap_or(DEFAULT_EMPTY_HASH));
        }
        let calculated_hash: [u8; 32] = hasher.finalize().into();
        if *self.hash.as_ref().unwrap_or(DEFAULT_EMPTY_HASH) != calculated_hash {
            return Err(self.label);
        }
        for child in self.children.iter() {
            if let Err(label) = child.verify() {
                return Err(label);
            }
        }
        Ok(())
    }
/// Returns Ok(()) if the tree is valid, otherwise, returns Err(label)
/// where label is the label of the first node with an mismatched hash.
Returns Ok(()) if the tree is valid, otherwise, returns Err(label)
where label is the label of the first node with an mismatched hash.
Returns Ok (( )) if the tree is valid otherwise returns Err ( label ) where label is the label of the first node with an mismatched hash .
fn verify(&self) -> Result<(), Label> {
        // Leaf nodes store a hash supplied by the user and are always valid.
        if self.is_leaf() {
            return Ok(());
        }
        let mut hasher = Sha256::new();
        for child in self.children.iter() {
            hasher.update(child.hash.as_ref().unwrap_or(DEFAULT_EMPTY_HASH));
        }
        let calculated_hash: [u8; 32] = hasher.finalize().into();
        if *self.hash.as_ref().unwrap_or(DEFAULT_EMPTY_HASH) != calculated_hash {
            return Err(self.label);
        }
        for child in self.children.iter() {
            if let Err(label) = child.verify() {
                return Err(label);
            }
        }
        Ok(())
    }
fn verify ( & self ) -> Result < ( ) , Label > { // Leaf nodes store a hash supplied by the user and are always valid. if self . is_leaf ( ) { return Ok ( ( ) ) ; } let mut hasher = Sha256 :: new ( ) ; for child in self . children . iter ( ) { hasher . update ( child . hash . as_ref ( ) . unwrap_or ( DEFAULT_EMPTY_HASH ) ) ; } let calculated_hash : [ u8 ; 32 ] = hasher . finalize ( ) . into ( ) ; if * self . hash . as_ref ( ) . unwrap_or ( DEFAULT_EMPTY_HASH ) != calculated_hash { return Err ( self . label ) ; } for child in self . children . iter ( ) { if let Err ( label ) = child . verify ( ) { return Err ( label ) ; } } Ok ( ( ) ) }
Returns Ok(()) if the tree is valid, otherwise, returns Err(label)
where label is the label of the first node with an mismatched hash.
Returns Ok (( )) if the tree is valid otherwise returns Err ( label ) where label is the label of the first node with an mismatched hash .
&self
&self