Skip to content

Commit

Permalink
core/rawdb: better error message in freezer (ethereum#23901)
Browse files Browse the repository at this point in the history
* core/rawdb: better error message in freezer

* Apply suggestions from code review
  • Loading branch information
holiman authored and jagdeep sidhu committed Nov 16, 2021
1 parent 3a253eb commit 8d27a68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/rawdb/freezer_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (batch *freezerTableBatch) reset() {
// existing data.
func (batch *freezerTableBatch) Append(item uint64, data interface{}) error {
if item != batch.curItem {
return errOutOrderInsertion
return fmt.Errorf("%w: have %d want %d", errOutOrderInsertion, item, batch.curItem)
}

// Encode the item.
Expand All @@ -136,7 +136,7 @@ func (batch *freezerTableBatch) Append(item uint64, data interface{}) error {
// existing data.
func (batch *freezerTableBatch) AppendRaw(item uint64, blob []byte) error {
if item != batch.curItem {
return errOutOrderInsertion
return fmt.Errorf("%w: have %d want %d", errOutOrderInsertion, item, batch.curItem)
}

encItem := blob
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/freezer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func TestFreezerConcurrentModifyTruncate(t *testing.T) {
if truncateErr != nil {
t.Fatal("concurrent truncate failed:", err)
}
if !(modifyErr == nil || modifyErr == errOutOrderInsertion) {
if !(errors.Is(modifyErr, nil) || errors.Is(modifyErr, errOutOrderInsertion)) {
t.Fatal("wrong error from concurrent modify:", modifyErr)
}
checkAncientCount(t, f, "test", 10)
Expand Down

0 comments on commit 8d27a68

Please sign in to comment.