-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4724 from multiversx/sync-missing-keys-only
add custom error for trie get node
- Loading branch information
Showing
74 changed files
with
502 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
package errors | ||
|
||
import ( | ||
"strings" | ||
"encoding/hex" | ||
"fmt" | ||
|
||
"github.com/multiversx/mx-chain-go/common" | ||
"github.com/multiversx/mx-chain-core-go/core" | ||
) | ||
|
||
// IsGetNodeFromDBError returns true if the provided error is of type getNodeFromDB | ||
func IsGetNodeFromDBError(err error) bool { | ||
if err == nil { | ||
return false | ||
} | ||
// GetNodeFromDBErrWithKey defines a custom error for trie get node | ||
type GetNodeFromDBErrWithKey struct { | ||
getErr error | ||
key []byte | ||
dbIdentifier string | ||
} | ||
|
||
if IsClosingError(err) { | ||
return false | ||
// NewGetNodeFromDBErrWithKey will create a new instance of GetNodeFromDBErrWithKey | ||
func NewGetNodeFromDBErrWithKey(key []byte, err error, id string) *GetNodeFromDBErrWithKey { | ||
return &GetNodeFromDBErrWithKey{ | ||
getErr: err, | ||
key: key, | ||
dbIdentifier: id, | ||
} | ||
} | ||
|
||
if strings.Contains(err.Error(), common.GetNodeFromDBErrorString) { | ||
return true | ||
} | ||
// Error returns the error as string | ||
func (e *GetNodeFromDBErrWithKey) Error() string { | ||
return fmt.Sprintf( | ||
"%s: %s for key %v", | ||
core.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 | ||
} | ||
|
||
return false | ||
// GetIdentifier will return the db identifier corresponding to the db | ||
func (e *GetNodeFromDBErrWithKey) GetIdentifier() string { | ||
return e.dbIdentifier | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.