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

Serve the latest block as pending block #38

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions turbo/jsonrpc/eth_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber
return nil, err
}
defer tx.Rollback()

chainConfig, err := api.chainConfig(tx)
if err != nil {
return nil, err
}
if chainConfig.IsOptimism() && number == rpc.PendingBlockNumber {
number = rpc.LatestBlockNumber
}

b, err := api.blockByNumber(ctx, number, tx)
log.Debug("MMDBG eth_block GetBlockByNumber", "n", number, "fullTx", fullTx, "err", err, "b", b)
if err != nil {
Expand All @@ -219,10 +228,6 @@ func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber
additionalFields["totalDifficulty"] = (*hexutil.Big)(td)
}

chainConfig, err := api.chainConfig(tx)
if err != nil {
return nil, err
}
var borTx types.Transaction
var borTxHash common.Hash
if chainConfig.Bor != nil {
Expand Down
Loading