Update pebble.go

This commit is contained in:
Avory 2025-11-01 02:20:47 +02:00 committed by GitHub
parent e6d34c1fee
commit f3ba4d9994
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -688,7 +688,15 @@ func (b *batch) Replay(w ethdb.KeyValueWriter) error {
for {
kind, k, v, ok, err := reader.Next()
if !ok || err != nil {
return err
// Provide better error context when batch is invalid.
// This error typically occurs when trying to read a corrupted batch.
if err != nil {
if strings.Contains(err.Error(), "invalid batch") {
return fmt.Errorf("decoding SET value: %w", err)
}
return err
}
return nil
}
// The (k,v) slices might be overwritten if the batch is reset/reused,
// and the receiver should copy them if they are to be retained long-term.