Commit 1bcee8f1 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

l2geth: fix `eth_getBlockRange` (#2390)

parent cc0594cf
---
'@eth-optimism/l2geth': patch
---
Fix `eth_getBlockRange`
......@@ -51,8 +51,9 @@ import (
)
var (
errNoSequencerURL = errors.New("sequencer transaction forwarding not configured")
errStillSyncing = errors.New("sequencer still syncing, cannot accept transactions")
errNoSequencerURL = errors.New("sequencer transaction forwarding not configured")
errStillSyncing = errors.New("sequencer still syncing, cannot accept transactions")
errBlockNotIndexed = errors.New("block in range not indexed, this should never happen")
)
const (
......@@ -780,9 +781,12 @@ func (s *PublicBlockChainAPI) GetBlockRange(ctx context.Context, startNumber rpc
// For each block in range, get block and append to array.
for number := startNumber; number <= endNumber; number++ {
block, err := s.GetBlockByNumber(ctx, number, fullTx)
if block == nil || err != nil {
if err != nil {
return nil, err
}
if block == nil {
return nil, errBlockNotIndexed
}
blocks = append(blocks, block)
}
return blocks, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment