mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
cmd/era: also check iterator error after loop
This commit is contained in:
parent
d367576093
commit
dccb358660
1 changed files with 5 additions and 2 deletions
|
|
@ -273,8 +273,8 @@ func checkAccumulator(e *era.Era) error {
|
||||||
// accumulation across the entire set and are verified at the end.
|
// accumulation across the entire set and are verified at the end.
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
// 1) next() walks the block index, so we're able to implicitly verify it.
|
// 1) next() walks the block index, so we're able to implicitly verify it.
|
||||||
if itErr := it.Error(); itErr != nil {
|
if it.Error() != nil {
|
||||||
return fmt.Errorf("error reading block %d: %w", it.Number(), itErr)
|
return fmt.Errorf("error reading block %d: %w", it.Number(), it.Error())
|
||||||
}
|
}
|
||||||
block, receipts, err := it.BlockAndReceipts()
|
block, receipts, err := it.BlockAndReceipts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -294,6 +294,9 @@ func checkAccumulator(e *era.Era) error {
|
||||||
td.Add(td, block.Difficulty())
|
td.Add(td, block.Difficulty())
|
||||||
tds = append(tds, new(big.Int).Set(td))
|
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.
|
// 4+5) Verify accumulator and total difficulty.
|
||||||
got, err := era.ComputeAccumulator(hashes, tds)
|
got, err := era.ComputeAccumulator(hashes, tds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue