in mfg/verify.go [127:155]
func (m *Mfg) VerifyStructure(eraseVal byte) error {
for _, t := range m.Tlvs() {
// Verify that TLV has a valid `type` field.
body, err := t.StructuredBody()
if err != nil {
return err
}
// Verify contents of hash TLV.
switch t.Header.Type {
case META_TLV_TYPE_HASH:
hashBody := body.(*MetaTlvBodyHash)
hash, err := m.RecalcHash(eraseVal)
if err != nil {
return err
}
if !bytes.Equal(hash, hashBody.Hash[:]) {
return errors.Errorf(
"mmr contains incorrect hash: have=%s want=%s",
hex.EncodeToString(hashBody.Hash[:]),
hex.EncodeToString(hash))
}
}
}
return nil
}