diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-24 19:12:01 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-24 19:12:01 +0800 |
commit | 55c1c220d07c37610c9aa61c583eccb3c8e3829e (patch) | |
tree | 11f135574c13409998ee598f66c02d55a3a45d27 | |
parent | 5971c82094b79e7c05bfb652c46fac02381b2816 (diff) | |
download | dexon-55c1c220d07c37610c9aa61c583eccb3c8e3829e.tar dexon-55c1c220d07c37610c9aa61c583eccb3c8e3829e.tar.gz dexon-55c1c220d07c37610c9aa61c583eccb3c8e3829e.tar.bz2 dexon-55c1c220d07c37610c9aa61c583eccb3c8e3829e.tar.lz dexon-55c1c220d07c37610c9aa61c583eccb3c8e3829e.tar.xz dexon-55c1c220d07c37610c9aa61c583eccb3c8e3829e.tar.zst dexon-55c1c220d07c37610c9aa61c583eccb3c8e3829e.zip |
Added delete to database interfaces
-rw-r--r-- | ethdb/database.go | 4 | ||||
-rw-r--r-- | ethdb/memory_database.go | 6 | ||||
-rw-r--r-- | ethutil/db.go | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/ethdb/database.go b/ethdb/database.go index 76e4b4e4d..1e987920d 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -36,6 +36,10 @@ func (db *LDBDatabase) Get(key []byte) ([]byte, error) { return db.db.Get(key, nil) } +func (db *LDBDatabase) Delete(key []byte) error { + return db.db.Delete(key, nil) +} + func (db *LDBDatabase) LastKnownTD() []byte { data, _ := db.db.Get([]byte("LastKnownTotalDifficulty"), nil) diff --git a/ethdb/memory_database.go b/ethdb/memory_database.go index cd9f24000..9e91eb7d6 100644 --- a/ethdb/memory_database.go +++ b/ethdb/memory_database.go @@ -26,6 +26,12 @@ func (db *MemDatabase) Get(key []byte) ([]byte, error) { return db.db[string(key)], nil } +func (db *MemDatabase) Delete(key []byte) error { + delete(db.db, string(key)) + + return nil +} + func (db *MemDatabase) Print() { for key, val := range db.db { fmt.Printf("%x(%d): ", key, len(key)) diff --git a/ethutil/db.go b/ethutil/db.go index 3681c4b05..b11d5d726 100644 --- a/ethutil/db.go +++ b/ethutil/db.go @@ -4,6 +4,7 @@ package ethutil type Database interface { Put(key []byte, value []byte) Get(key []byte) ([]byte, error) + Delete(key []byte) error LastKnownTD() []byte Close() Print() |