-
Notifications
You must be signed in to change notification settings - Fork 21k
fix nil pointer when block does not exist #31116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,9 +114,6 @@ func (api *API) blockByNumber(ctx context.Context, number rpc.BlockNumber) (*typ | |
if err != nil { | ||
return nil, err | ||
} | ||
if block == nil { | ||
return nil, fmt.Errorf("block #%d not found", number) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return block, nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1746,9 +1746,9 @@ func (api *DebugAPI) GetRawTransaction(ctx context.Context, hash common.Hash) (h | |
|
||
// PrintBlock retrieves a block and returns its pretty printed form. | ||
func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error) { | ||
block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number)) | ||
if block == nil { | ||
return "", fmt.Errorf("block #%d not found", number) | ||
block, err := api.b.BlockByNumber(ctx, rpc.BlockNumber(number)) | ||
if err != nil { | ||
return "", err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
return spew.Sdump(block), nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define this as an error, so it can be caught and handled