func mustConvertBloom(in string) types.Bloom { out, err := hex.DecodeString(strings.TrimPrefix(in, "0x")) if err != nil { panic(fmt.Errorf("invalid hex: %q", in)) } return types.BytesToBloom(out) }
// WriteMapmapBloom writes each address included in the receipts' logs to the // MIP bloom bin. func WriteMipmapBloom(db ethdb.Database, number uint64, receipts types.Receipts) error { batch := db.NewBatch() for _, level := range MIPMapLevels { key := mipmapKey(number, level) bloomDat, _ := db.Get(key) bloom := types.BytesToBloom(bloomDat) for _, receipt := range receipts { for _, log := range receipt.Logs { bloom.Add(log.Address.Big()) } } batch.Put(key, bloom.Bytes()) } if err := batch.Write(); err != nil { return fmt.Errorf("mipmap write fail for: %d: %v", number, err) } return nil }
// GetMipmapBloom returns a bloom filter using the number and level as input // parameters. For available levels see MIPMapLevels. func GetMipmapBloom(db ethdb.Database, number, level uint64) types.Bloom { bloomDat, _ := db.Get(mipmapKey(number, level)) return types.BytesToBloom(bloomDat) }