Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
zsfelfoldi committed Oct 24, 2024
1 parent e140ff2 commit 30fd63f
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions core/filtermaps/filtermaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,36 @@ func (f *FilterMaps) removeBloomBits() {
// removeDbWithPrefix removes data with the given prefix from the database and
// returns true if everything was successfully removed.
func (f *FilterMaps) removeDbWithPrefix(prefix []byte, action string) bool {
end := bytes.Clone(prefix)
end[len(end)-1]++

it := f.db.NewIterator(prefix, nil)
hadData := it.Next()
hasData := it.Next()
it.Release()
if !hasData {
return true
}

end := bytes.Clone(prefix)
end[len(end)-1]++
start := time.Now()
if err := f.db.DeleteRange(prefix, end); err == nil {
if hadData {
var retry bool
for {
err := f.db.DeleteRange(prefix, end)
if err == nil {
log.Info(action+" finished", "elapsed", time.Since(start))
return true
}
if err != ethdb.ErrTooManyKeys {
log.Error(action+" failed", "error", err)
return false
}
select {
case <-f.closeCh:
return false
default:
}
if !retry {
log.Info(action + " in progress...")
retry = true
}
return true
} else {
log.Error(action+" failed", "error", err)
return false
}
}

Expand Down

0 comments on commit 30fd63f

Please sign in to comment.