internal/ethapi: fix panic in debug methods (#31157)

Fixes an error when the block is not found in debug methods.
This commit is contained in:
Sina M 2025-02-11 16:02:30 +01:00 committed by Arran Schlosberg
parent 955616d7c2
commit 7b6ff3e0ff
No known key found for this signature in database
GPG key ID: 5DD5567C12C5F312

View file

@ -1992,7 +1992,7 @@ func (api *DebugAPI) GetRawHeader(ctx context.Context, blockNrOrHash rpc.BlockNu
hash = h
} else {
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
if err != nil {
if block == nil || err != nil {
return nil, err
}
hash = block.Hash()
@ -2011,7 +2011,7 @@ func (api *DebugAPI) GetRawBlock(ctx context.Context, blockNrOrHash rpc.BlockNum
hash = h
} else {
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
if err != nil {
if block == nil || err != nil {
return nil, err
}
hash = block.Hash()
@ -2030,7 +2030,7 @@ func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.Block
hash = h
} else {
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
if err != nil {
if block == nil || err != nil {
return nil, err
}
hash = block.Hash()