File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ import (
6
6
"bytes"
7
7
"encoding/binary"
8
8
"encoding/hex"
9
+ "errors"
10
+
9
11
"github.com/syndtr/goleveldb/leveldb"
10
12
"github.com/syndtr/goleveldb/leveldb/util"
11
- "log"
12
13
)
13
14
14
15
// todo change to `var NoEntryErr = errors.new("[no entry found]")`
@@ -93,15 +94,16 @@ func insertBatch(db *leveldb.DB, pairs []types.Pair) error {
93
94
func retrieveByBlockHash (db * leveldb.DB , blockHash string , pair types.Pair ) error {
94
95
blockHashBytes , err := hex .DecodeString (blockHash )
95
96
if err != nil {
96
- log .Println (err )
97
+ common . ErrorLogger .Println (err )
97
98
return err
98
99
}
99
100
100
101
data , err := db .Get (blockHashBytes , nil )
101
- if err != nil && err . Error () != "leveldb: not found" { // todo this error probably exists as var/type somewhere
102
+ if err != nil && ! errors . Is ( err , NoEntryErr {}) { // todo this error probably exists as var/type somewhere
102
103
common .ErrorLogger .Println (err )
103
104
return err
104
- } else if err != nil && err .Error () == "leveldb: not found" { // todo this error probably exists as var/type somewhere
105
+ } else if err != nil && errors .Is (err , NoEntryErr {}) { // todo this error probably exists as var/type somewhere
106
+ // todo we don't need separate patterns if just return the errors anyways? or maybe just to avoid unnecessary logging
105
107
return NoEntryErr {}
106
108
}
107
109
if len (data ) == 0 {
You can’t perform that action at this time.
0 commit comments