Skip to content

Commit 8e394ec

Browse files
s1naqdm12
authored andcommitted
internal/ethapi: fix panic in debug methods (ethereum#31157)
Fixes an error when the block is not found in debug methods.
1 parent 9016ae4 commit 8e394ec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/ethapi/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,7 @@ func (api *DebugAPI) GetRawHeader(ctx context.Context, blockNrOrHash rpc.BlockNu
19921992
hash = h
19931993
} else {
19941994
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
1995-
if err != nil {
1995+
if block == nil || err != nil {
19961996
return nil, err
19971997
}
19981998
hash = block.Hash()
@@ -2011,7 +2011,7 @@ func (api *DebugAPI) GetRawBlock(ctx context.Context, blockNrOrHash rpc.BlockNum
20112011
hash = h
20122012
} else {
20132013
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
2014-
if err != nil {
2014+
if block == nil || err != nil {
20152015
return nil, err
20162016
}
20172017
hash = block.Hash()
@@ -2030,7 +2030,7 @@ func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.Block
20302030
hash = h
20312031
} else {
20322032
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
2033-
if err != nil {
2033+
if block == nil || err != nil {
20342034
return nil, err
20352035
}
20362036
hash = block.Hash()

0 commit comments

Comments
 (0)