forked from cerc-io/plugeth
Added delete to database interfaces
This commit is contained in:
parent
5971c82094
commit
55c1c220d0
@ -36,6 +36,10 @@ func (db *LDBDatabase) Get(key []byte) ([]byte, error) {
|
|||||||
return db.db.Get(key, nil)
|
return db.db.Get(key, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *LDBDatabase) Delete(key []byte) error {
|
||||||
|
return db.db.Delete(key, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func (db *LDBDatabase) LastKnownTD() []byte {
|
func (db *LDBDatabase) LastKnownTD() []byte {
|
||||||
data, _ := db.db.Get([]byte("LastKnownTotalDifficulty"), nil)
|
data, _ := db.db.Get([]byte("LastKnownTotalDifficulty"), nil)
|
||||||
|
|
||||||
|
@ -26,6 +26,12 @@ func (db *MemDatabase) Get(key []byte) ([]byte, error) {
|
|||||||
return db.db[string(key)], nil
|
return db.db[string(key)], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *MemDatabase) Delete(key []byte) error {
|
||||||
|
delete(db.db, string(key))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (db *MemDatabase) Print() {
|
func (db *MemDatabase) Print() {
|
||||||
for key, val := range db.db {
|
for key, val := range db.db {
|
||||||
fmt.Printf("%x(%d): ", key, len(key))
|
fmt.Printf("%x(%d): ", key, len(key))
|
||||||
|
@ -4,6 +4,7 @@ package ethutil
|
|||||||
type Database interface {
|
type Database interface {
|
||||||
Put(key []byte, value []byte)
|
Put(key []byte, value []byte)
|
||||||
Get(key []byte) ([]byte, error)
|
Get(key []byte) ([]byte, error)
|
||||||
|
Delete(key []byte) error
|
||||||
LastKnownTD() []byte
|
LastKnownTD() []byte
|
||||||
Close()
|
Close()
|
||||||
Print()
|
Print()
|
||||||
|
Loading…
Reference in New Issue
Block a user