Skip to content

Commit

Permalink
Merge branch 'dev' into update-versions-v1.10.17
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Dec 1, 2023
2 parents 8175397 + be1a2ad commit 5b4ca26
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions chains/atomic/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package atomic
import (
"bytes"
"errors"
"fmt"

"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/database/linkeddb"
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5b4ca26

Please sign in to comment.