@@ -18,10 +18,14 @@ package rawdb
18
18
19
19
import (
20
20
"encoding/binary"
21
+ "errors"
21
22
23
+ "github.com/cockroachdb/pebble"
22
24
"github.com/ethereum/go-ethereum/common"
23
25
"github.com/ethereum/go-ethereum/ethdb"
26
+ "github.com/ethereum/go-ethereum/ethdb/memorydb"
24
27
"github.com/ethereum/go-ethereum/log"
28
+ "github.com/syndtr/goleveldb/leveldb"
25
29
)
26
30
27
31
// ReadSnapshotDisabled retrieves if the snapshot maintenance is disabled.
@@ -72,9 +76,20 @@ func DeleteSnapshotRoot(db ethdb.KeyValueWriter) {
72
76
}
73
77
}
74
78
79
+ func isDbErrNotFound (err error ) bool {
80
+ return errors .Is (err , leveldb .ErrNotFound ) || errors .Is (err , pebble .ErrNotFound ) || errors .Is (err , memorydb .ErrMemorydbNotFound )
81
+ }
82
+
83
+ func ignoreNotFound (blob []byte , err error ) ([]byte , error ) {
84
+ if isDbErrNotFound (err ) {
85
+ return nil , nil
86
+ }
87
+ return blob , err
88
+ }
89
+
75
90
// ReadAccountSnapshot retrieves the snapshot entry of an account trie leaf.
76
91
func ReadAccountSnapshot (db ethdb.KeyValueReader , hash common.Hash ) ([]byte , error ) {
77
- return db .Get (accountSnapshotKey (hash ))
92
+ return ignoreNotFound ( db .Get (accountSnapshotKey (hash ) ))
78
93
}
79
94
80
95
// WriteAccountSnapshot stores the snapshot entry of an account trie leaf.
@@ -93,7 +108,7 @@ func DeleteAccountSnapshot(db ethdb.KeyValueWriter, hash common.Hash) {
93
108
94
109
// ReadStorageSnapshot retrieves the snapshot entry of an storage trie leaf.
95
110
func ReadStorageSnapshot (db ethdb.KeyValueReader , accountHash , storageHash common.Hash ) ([]byte , error ) {
96
- return db .Get (storageSnapshotKey (accountHash , storageHash ))
111
+ return ignoreNotFound ( db .Get (storageSnapshotKey (accountHash , storageHash ) ))
97
112
}
98
113
99
114
// WriteStorageSnapshot stores the snapshot entry of an storage trie leaf.
0 commit comments