Skip to content

Commit

Permalink
- fixed log print on getNodeFromDB error
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianpascalau committed Mar 24, 2023
1 parent 99aa1b6 commit ee6bb31
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion trie/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/errors"
"github.com/multiversx/mx-chain-go/trie/keyBuilder"
logger "github.com/multiversx/mx-chain-logger-go"
)

const (
Expand Down Expand Up @@ -120,7 +121,12 @@ func computeAndSetNodeHash(n node) ([]byte, error) {
func getNodeFromDBAndDecode(n []byte, db common.DBWriteCacher, marshalizer marshal.Marshalizer, hasher hashing.Hasher) (node, error) {
encChild, err := db.Get(n)
if err != nil {
log.Warn(common.GetNodeFromDBErrorString, "error", err, "key", n, "stack trace", string(debug.Stack()))
logLevel := logger.LogWarning
if errors.IsClosingError(err) {
logLevel = logger.LogTrace
}

log.Log(logLevel, common.GetNodeFromDBErrorString, "error", err, "key", n, "stack trace", string(debug.Stack()))
return nil, fmt.Errorf(common.GetNodeFromDBErrorString+" %w for key %v", err, hex.EncodeToString(n))
}

Expand Down

0 comments on commit ee6bb31

Please sign in to comment.