Skip to content
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

[chains/atomic] Remove a nested if statement #3135

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions chains/atomic/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,7 @@ func (s *state) SetValue(e *Element) error {
// current engine state.
func (s *state) RemoveValue(key []byte) error {
value, err := s.loadValue(key)
if err != nil {
if err != database.ErrNotFound {
// An unexpected error occurred, so we should propagate that error
return err
}

if err == database.ErrNotFound {
// The value doesn't exist, so we should optimistically delete it
dbElem := dbElement{Present: false}
valueBytes, err := Codec.Marshal(CodecVersion, &dbElem)
Expand All @@ -161,6 +156,10 @@ func (s *state) RemoveValue(key []byte) error {
}
return s.valueDB.Put(key, valueBytes)
}
if err != nil {
// An unexpected error occurred, so we should propagate that error
dhrubabasu marked this conversation as resolved.
Show resolved Hide resolved
dhrubabasu marked this conversation as resolved.
Show resolved Hide resolved
return err
}

// Don't allow the removal of something that was already removed.
if !value.Present {
Expand Down
Loading