Skip to content

Commit a1dd97d

Browse files
committed
core/filtermaps: delete old bloombits database at startup
1 parent e1f4f3c commit a1dd97d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

core/filtermaps/filtermaps.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ func (f *FilterMaps) Start() {
233233
log.Error("Could not load head filter map snapshot", "error", err)
234234
}
235235
}
236-
f.closeWg.Add(1)
236+
f.closeWg.Add(2)
237+
go f.removeBloomBits()
237238
go f.indexerLoop()
238239
}
239240

@@ -328,6 +329,13 @@ func (f *FilterMaps) init() error {
328329
return batch.Write()
329330
}
330331

332+
// removeBloomBits removes old bloom bits data from the database.
333+
func (f *FilterMaps) removeBloomBits() {
334+
f.removeDbWithPrefix(rawdb.BloomBitsPrefix, "Removing old bloom bits database")
335+
f.removeDbWithPrefix(rawdb.BloomBitsIndexPrefix, "Removing old bloom bits chain index")
336+
f.closeWg.Done()
337+
}
338+
331339
// removeDbWithPrefix removes data with the given prefix from the database and
332340
// returns true if everything was successfully removed.
333341
func (f *FilterMaps) removeDbWithPrefix(prefix []byte, action string) bool {

core/rawdb/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ var (
106106
blockReceiptsPrefix = []byte("r") // blockReceiptsPrefix + num (uint64 big endian) + hash -> block receipts
107107

108108
txLookupPrefix = []byte("l") // txLookupPrefix + hash -> transaction/receipt lookup metadata
109-
bloomBitsPrefix = []byte("B") // bloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash -> bloom bits
109+
BloomBitsPrefix = []byte("B") // BloomBitsPrefix + bit (uint16 big endian) + section (uint64 big endian) + hash -> bloom bits
110110
SnapshotAccountPrefix = []byte("a") // SnapshotAccountPrefix + account hash -> account trie value
111111
SnapshotStoragePrefix = []byte("o") // SnapshotStoragePrefix + account hash + storage hash -> storage trie value
112112
CodePrefix = []byte("c") // CodePrefix + code hash -> account code

0 commit comments

Comments
 (0)