Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Fix non-idiomatic error check (#18)
Browse files Browse the repository at this point in the history
* Fix to idiomatic err != nil.

* Update smt.go

Fix return to `nil` to error

Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl>

* Update smt.go

Return `nil` error on success.

Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl>

Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl>
  • Loading branch information
adlerjohn and tzdybal committed Mar 9, 2021
1 parent 2b025d3 commit edfd329
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions smt.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ func (smt *SparseMerkleTree) HasForRoot(key, root []byte) (bool, error) {
// Update sets a new value for a key in the tree, and sets and returns the new root of the tree.
func (smt *SparseMerkleTree) Update(key []byte, value []byte) ([]byte, error) {
newRoot, err := smt.UpdateForRoot(key, value, smt.Root())
if err == nil {
smt.SetRoot(newRoot)
if err != nil {
return nil, err
}
return newRoot, err
smt.SetRoot(newRoot)
return newRoot, nil
}

// Delete deletes a value from tree. It returns the new root of the tree.
Expand Down

0 comments on commit edfd329

Please sign in to comment.