aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb/memory_database.go
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2018-07-02 16:16:30 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-07-02 16:16:30 +0800
commita4a2343cdc1946e38da1aea1476642d1744c1354 (patch)
treec01c563224aaf34a1a391665bcca0b693b9cf0ce /ethdb/memory_database.go
parentfdfd6d3c3963b1b3459e4625458495458b11e8a7 (diff)
downloaddexon-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.gz
dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.tar.zst
dexon-a4a2343cdc1946e38da1aea1476642d1744c1354.zip
ethdb, core: implement delete for db batch (#17101)
Diffstat (limited to 'ethdb/memory_database.go')
-rw-r--r--ethdb/memory_database.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/ethdb/memory_database.go b/ethdb/memory_database.go
index c57042920..f28ff5481 100644
--- a/ethdb/memory_database.go
+++ b/ethdb/memory_database.go
@@ -110,11 +110,20 @@ func (b *memBatch) Put(key, value []byte) error {
return nil
}
+func (b *memBatch) Delete(key []byte) error {
+ b.writes = append(b.writes, kv{common.CopyBytes(key), nil})
+ return nil
+}
+
func (b *memBatch) Write() error {
b.db.lock.Lock()
defer b.db.lock.Unlock()
for _, kv := range b.writes {
+ if kv.v == nil {
+ delete(b.db.db, string(kv.k))
+ continue
+ }
b.db.db[string(kv.k)] = kv.v
}
return nil