Skip to content
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

pending block will only return if it is not nil #4588

Merged
merged 2 commits into from
Jul 1, 2022

Conversation

enriavil1
Copy link
Contributor

@enriavil1 enriavil1 commented Jun 30, 2022

In some scenarios we are always returning nil as pending block number, while in rpchelper.GetBlockByNumber will return the latest block inside of our cache which we never get to do because of the initial if statement.

@@ -213,10 +213,6 @@ func (api *BaseAPI) pendingBlock() *types.Block {
}

func (api *BaseAPI) blockByRPCNumber(number rpc.BlockNumber, tx kv.Tx) (*types.Block, error) {
if number == rpc.PendingBlockNumber {
return api.pendingBlock(), nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t understand. What we will return if user requested pending block?

Copy link
Contributor Author

@enriavil1 enriavil1 Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rpchelper.GetBlockNumber already deals with pending block number in a new way. It first checks wether we have pending block and if we don't then we return the plain state block number instead. We essentially return the pendingBlockNumber or the plainStateBlockNumber but never nil.

@AskAlexSharov AskAlexSharov merged commit fa29987 into devel Jul 1, 2022
@AskAlexSharov AskAlexSharov deleted the pending-block-nil branch July 1, 2022 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants