From dccb35866043ca6838b5faa20b9953f06fda108a Mon Sep 17 00:00:00 2001 From: lightclient Date: Mon, 22 Sep 2025 11:48:58 -0600 Subject: [PATCH] cmd/era: also check iterator error after loop --- cmd/era/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/era/main.go b/cmd/era/main.go index 893db3787a..35a889d4dc 100644 --- a/cmd/era/main.go +++ b/cmd/era/main.go @@ -273,8 +273,8 @@ func checkAccumulator(e *era.Era) error { // accumulation across the entire set and are verified at the end. for it.Next() { // 1) next() walks the block index, so we're able to implicitly verify it. - if itErr := it.Error(); itErr != nil { - return fmt.Errorf("error reading block %d: %w", it.Number(), itErr) + if it.Error() != nil { + return fmt.Errorf("error reading block %d: %w", it.Number(), it.Error()) } block, receipts, err := it.BlockAndReceipts() if err != nil { @@ -294,6 +294,9 @@ func checkAccumulator(e *era.Era) error { td.Add(td, block.Difficulty()) tds = append(tds, new(big.Int).Set(td)) } + if it.Error() != nil { + return fmt.Errorf("error reading block %d: %w", it.Number(), it.Error()) + } // 4+5) Verify accumulator and total difficulty. got, err := era.ComputeAccumulator(hashes, tds) if err != nil {