added deletion support (#4451)

This commit is contained in:
Giulio rebuffo 2022-06-14 21:43:44 +02:00 committed by GitHub
parent 7f81e0ddde
commit cad32ee1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -289,6 +289,20 @@ func (m *memorymutation) Flush(tx kv.RwTx) error {
if err != nil {
return err
}
// Obliterate buckets who are to be deleted
for bucket := range m.clearedTables {
if err := tx.ClearBucket(bucket); err != nil {
return err
}
}
// Obliterate entries who are to be deleted
for bucket, keys := range m.deletedEntries {
for key := range keys {
if err := tx.Delete(bucket, []byte(key), nil); err != nil {
return err
}
}
}
// Iterate over each bucket and apply changes accordingly.
for _, bucket := range buckets {
if _, ok := m.dupsortTables[bucket]; ok && bucket != kv.HashedStorage {