forked from cerc-io/plugeth
core/rawdb: better error message in freezer (#23901)
* core/rawdb: better error message in freezer * Apply suggestions from code review
This commit is contained in:
parent
05acc272b5
commit
b7a6409cc1
@ -116,7 +116,7 @@ func (batch *freezerTableBatch) reset() {
|
|||||||
// existing data.
|
// existing data.
|
||||||
func (batch *freezerTableBatch) Append(item uint64, data interface{}) error {
|
func (batch *freezerTableBatch) Append(item uint64, data interface{}) error {
|
||||||
if item != batch.curItem {
|
if item != batch.curItem {
|
||||||
return errOutOrderInsertion
|
return fmt.Errorf("%w: have %d want %d", errOutOrderInsertion, item, batch.curItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode the item.
|
// Encode the item.
|
||||||
@ -136,7 +136,7 @@ func (batch *freezerTableBatch) Append(item uint64, data interface{}) error {
|
|||||||
// existing data.
|
// existing data.
|
||||||
func (batch *freezerTableBatch) AppendRaw(item uint64, blob []byte) error {
|
func (batch *freezerTableBatch) AppendRaw(item uint64, blob []byte) error {
|
||||||
if item != batch.curItem {
|
if item != batch.curItem {
|
||||||
return errOutOrderInsertion
|
return fmt.Errorf("%w: have %d want %d", errOutOrderInsertion, item, batch.curItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
encItem := blob
|
encItem := blob
|
||||||
|
@ -246,7 +246,7 @@ func TestFreezerConcurrentModifyTruncate(t *testing.T) {
|
|||||||
if truncateErr != nil {
|
if truncateErr != nil {
|
||||||
t.Fatal("concurrent truncate failed:", err)
|
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)
|
t.Fatal("wrong error from concurrent modify:", modifyErr)
|
||||||
}
|
}
|
||||||
checkAncientCount(t, f, "test", 10)
|
checkAncientCount(t, f, "test", 10)
|
||||||
|
Loading…
Reference in New Issue
Block a user