Revert "ethdb: rewrite leveldb/pebble/memorydb notfound to ethdb.notfound"

This reverts commit 108adb6a7a.

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2023-09-05 19:48:43 +08:00
parent fecb26c1b0
commit 0ef7483b49
3 changed files with 7 additions and 16 deletions

View file

@ -191,9 +191,6 @@ func (db *Database) Has(key []byte) (bool, error) {
func (db *Database) Get(key []byte) ([]byte, error) {
dat, err := db.db.Get(key, nil)
if err != nil {
if err == leveldb.ErrNotFound {
return nil, ethdb.ErrNotFound
}
return nil, err
}
return dat, nil
@ -472,11 +469,7 @@ func (snap *snapshot) Has(key []byte) (bool, error) {
// Get retrieves the given key if it's present in the snapshot backing by
// key-value data store.
func (snap *snapshot) Get(key []byte) ([]byte, error) {
val, err := snap.db.Get(key, nil)
if err == leveldb.ErrNotFound {
return nil, ethdb.ErrNotFound
}
return val, err
return snap.db.Get(key, nil)
}
// Release releases associated resources. Release should always succeed and can

View file

@ -32,6 +32,10 @@ var (
// invocation of a data access operation.
errMemorydbClosed = errors.New("database closed")
// errMemorydbNotFound is returned if a key is requested that is not found in
// the provided memory database.
errMemorydbNotFound = errors.New("not found")
// errSnapshotReleased is returned if callers want to retrieve data from a
// released snapshot.
errSnapshotReleased = errors.New("snapshot released")
@ -94,7 +98,7 @@ func (db *Database) Get(key []byte) ([]byte, error) {
if entry, ok := db.db[string(key)]; ok {
return common.CopyBytes(entry), nil
}
return nil, ethdb.ErrNotFound
return nil, errMemorydbNotFound
}
// Put inserts the given value into the key-value store.
@ -373,7 +377,7 @@ func (snap *snapshot) Get(key []byte) ([]byte, error) {
if entry, ok := snap.db[string(key)]; ok {
return common.CopyBytes(entry), nil
}
return nil, ethdb.ErrNotFound
return nil, errMemorydbNotFound
}
// Release releases associated resources. Release should always succeed and can

View file

@ -267,9 +267,6 @@ func (d *Database) Get(key []byte) ([]byte, error) {
}
dat, closer, err := d.db.Get(key)
if err != nil {
if err == pebble.ErrNotFound {
return nil, ethdb.ErrNotFound
}
return nil, err
}
ret := make([]byte, len(dat))
@ -353,9 +350,6 @@ func (snap *snapshot) Has(key []byte) (bool, error) {
func (snap *snapshot) Get(key []byte) ([]byte, error) {
dat, closer, err := snap.db.Get(key)
if err != nil {
if err == pebble.ErrNotFound {
return nil, ethdb.ErrNotFound
}
return nil, err
}
ret := make([]byte, len(dat))