-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add custom error for trie get node #4724
Changes from 16 commits
088cc58
e0dbd57
004264c
0d6e8d6
0141588
8b2d6e4
8d6ea22
3bcb4a3
4462ced
6c5d073
d7e1b6b
ac87c63
113c833
482aecb
737c93e
5f852a3
349d22a
3548ad0
bec60f1
ff5674d
094f227
0a17029
73275b1
a2deeff
65e517f
7dceb49
a683564
36ddeb4
7123970
a99d8d7
141ad52
aea1014
6d65587
25dc1d4
3e522d6
90c6e21
2a46bcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package errors | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/ElrondNetwork/elrond-go/common" | ||
|
@@ -22,3 +24,39 @@ func IsGetNodeFromDBError(err error) bool { | |
|
||
return false | ||
} | ||
|
||
// GetNodeFromDBErrWithKey defines a custom error for trie get node | ||
type GetNodeFromDBErrWithKey struct { | ||
getErr error | ||
key []byte | ||
dbIdentifier string | ||
} | ||
|
||
// NewGetNodeFromDBErrWithKey will create a new instance of GetNodeFromDBErr | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GetNodeFromDBErrWithKey? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
func NewGetNodeFromDBErrWithKey(key []byte, err error, id string) *GetNodeFromDBErrWithKey { | ||
return &GetNodeFromDBErrWithKey{ | ||
getErr: err, | ||
key: key, | ||
dbIdentifier: id, | ||
} | ||
} | ||
|
||
// Error returns the error as string | ||
func (e *GetNodeFromDBErrWithKey) Error() string { | ||
return fmt.Sprintf( | ||
"%s: %s for key %v", | ||
common.GetNodeFromDBErrorString, | ||
e.getErr.Error(), | ||
hex.EncodeToString(e.key), | ||
) | ||
} | ||
|
||
// GetKey will return the key that generated the error | ||
func (e *GetNodeFromDBErrWithKey) GetKey() []byte { | ||
return e.key | ||
} | ||
|
||
// GetIdentifier will return the db identifier corresponding to the db | ||
func (e *GetNodeFromDBErrWithKey) GetIdentifier() string { | ||
return e.dbIdentifier | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1033,6 +1033,11 @@ func (ps *PruningStorer) RangeKeys(_ func(key []byte, val []byte) bool) { | |
debug.PrintStack() | ||
} | ||
|
||
// GetIdentifier returns the identifier for storer | ||
func (ps *PruningStorer) GetIdentifier() string { | ||
return ps.identifier | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that if we somehow, change the paths and names for the accounts storers, the whole code will break. We need to find a proper way to use storers identifiers in this case. Perhaps using the trie containers implementation as seen in factory/state/stateComponents.go L151-L178? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from what i've tested, it still seems to work, will think more on the refactoring here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Works for now because the strings from both constant sets are the same. Will need to refactor this somehow. You can refactor now or add a TODO + task. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added todo and separate task for this |
||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (ps *PruningStorer) IsInterfaceNil() bool { | ||
return ps == nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.