diff options
author | gary rong <garyrong0905@gmail.com> | 2018-07-02 16:16:30 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-07-02 16:16:30 +0800 |
commit | a4a2343cdc1946e38da1aea1476642d1744c1354 (patch) | |
tree | c01c563224aaf34a1a391665bcca0b693b9cf0ce /ethdb/memory_database.go | |
parent | fdfd6d3c3963b1b3459e4625458495458b11e8a7 (diff) | |
download | dexon-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.go | 9 |
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 |