Skip to content

Commit 005a47c

Browse files
committed
core/filtermaps: delete old bloombits database at startup
1 parent 4d7a58c commit 005a47c

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
@@ -241,7 +241,8 @@ func (f *FilterMaps) Start() {
241241
log.Error("Could not load head filter map snapshot", "error", err)
242242
}
243243
}
244-
f.closeWg.Add(1)
244+
f.closeWg.Add(2)
245+
go f.removeBloomBits()
245246
go f.indexerLoop()
246247
}
247248

@@ -334,6 +335,13 @@ func (f *FilterMaps) init() error {
334335
return batch.Write()
335336
}
336337

338+
// removeBloomBits removes old bloom bits data from the database.
339+
func (f *FilterMaps) removeBloomBits() {
340+
f.removeDbWithPrefix(rawdb.BloomBitsPrefix, "Removing old bloom bits database")
341+
f.removeDbWithPrefix(rawdb.BloomBitsIndexPrefix, "Removing old bloom bits chain index")
342+
f.closeWg.Done()
343+
}
344+
337345
// removeDbWithPrefix removes data with the given prefix from the database and
338346
// returns true if everything was successfully removed.
339347
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)