Skip to content

Commit da71839

Browse files
authored
internal/ethapi: fix panic in debug methods (#31157)
Fixes an error when the block is not found in debug methods.
1 parent cdb66c8 commit da71839

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
@@ -1675,7 +1675,7 @@ func (api *DebugAPI) GetRawHeader(ctx context.Context, blockNrOrHash rpc.BlockNu
16751675
hash = h
16761676
} else {
16771677
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
1678-
if err != nil {
1678+
if block == nil || err != nil {
16791679
return nil, err
16801680
}
16811681
hash = block.Hash()
@@ -1694,7 +1694,7 @@ func (api *DebugAPI) GetRawBlock(ctx context.Context, blockNrOrHash rpc.BlockNum
16941694
hash = h
16951695
} else {
16961696
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
1697-
if err != nil {
1697+
if block == nil || err != nil {
16981698
return nil, err
16991699
}
17001700
hash = block.Hash()
@@ -1713,7 +1713,7 @@ func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.Block
17131713
hash = h
17141714
} else {
17151715
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
1716-
if err != nil {
1716+
if block == nil || err != nil {
17171717
return nil, err
17181718
}
17191719
hash = block.Hash()

0 commit comments

Comments
 (0)