// Validate Entry Block by merkle root func validateEBlockByMR(cid *common.Hash, mr *common.Hash) error { eb, err := db.FetchEBlockByMR(mr) if err != nil { return err } if eb == nil { return errors.New("Entry block not found in db for merkle root: " + mr.String()) } keyMR, err := eb.KeyMR() if err != nil { return err } if !mr.IsSameAs(keyMR) { return errors.New("Entry block's merkle root does not match with: " + mr.String()) } for _, ebEntry := range eb.Body.EBEntries { if !bytes.Equal(ebEntry.Bytes()[:31], common.ZERO_HASH[:31]) { entry, _ := db.FetchEntryByHash(ebEntry) if entry == nil { return errors.New("Entry not found in db for entry hash: " + ebEntry.String()) } } // Else ... we could do a bit more validation of the minute markers. } return nil }