Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerLamTd committed Dec 19, 2023
1 parent 377c52b commit 7a4b5ae
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions eth/taiko_api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,16 @@ func (s *TaikoAPIBackend) TxPoolContent(

// Get L2ParentBlocks retrieves the preceding 256 parent blocks given a block number.
func (s *TaikoAPIBackend) GetL2ParentHeaders(blockID uint64) ([]*types.Header, error) {
var headers []*types.Header
for i := blockID; i > 0 && len(headers) < 256; i-- {
headers = append(headers, s.eth.blockchain.GetHeaderByNumber(blockID-i))
headers := make([]*types.Header, 0, 256)
start := 0
if blockID > 256 {
start = int(blockID - 256)
}

for start < int(blockID) {
headers = append(headers, s.eth.blockchain.GetHeaderByNumber(uint64(start)))
start++
}

return headers, nil
}

0 comments on commit 7a4b5ae

Please sign in to comment.