diff --git a/chains/atomic/state.go b/chains/atomic/state.go index cd7a3f2a0faa..aee269915ea9 100644 --- a/chains/atomic/state.go +++ b/chains/atomic/state.go @@ -6,6 +6,7 @@ package atomic import ( "bytes" "errors" + "fmt" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/database/linkeddb" @@ -16,7 +17,10 @@ import ( "github.com/ava-labs/avalanchego/utils/set" ) -var errDuplicatedOperation = errors.New("duplicated operation on provided value") +var ( + errDuplicatePut = errors.New("duplicate put") + errDuplicateRemove = errors.New("duplicate remove") +) type dbElement struct { // Present indicates the value was removed before existing. @@ -86,7 +90,7 @@ func (s *state) SetValue(e *Element) error { } // This key was written twice, which is invalid - return errDuplicatedOperation + return fmt.Errorf("%w: Key=0x%x Value=0x%x", errDuplicatePut, e.Key, e.Value) } if err != database.ErrNotFound { // An unexpected error occurred, so we should propagate that error @@ -160,7 +164,7 @@ func (s *state) RemoveValue(key []byte) error { // Don't allow the removal of something that was already removed. if !value.Present { - return errDuplicatedOperation + return fmt.Errorf("%w: Key=0x%x", errDuplicateRemove, key) } // Remove [key] from the indexDB for each trait that has indexed this key.