Skip to content

Commit

Permalink
eth: let function HeaderByNumber return error when header is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Mar 12, 2024
1 parent f340875 commit b2a767e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ func (b *EthApiBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNum
return nil, errors.New("PoS V1 does not support confirmed block lookup")
}
}
return b.eth.blockchain.GetHeaderByNumber(uint64(blockNr)), nil
header := b.eth.blockchain.GetHeaderByNumber(uint64(blockNr))
if header == nil {
return nil, errors.New("header for number not found")
}
return header, nil
}

func (b *EthApiBackend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error) {
Expand Down

0 comments on commit b2a767e

Please sign in to comment.