Skip to content

Commit

Permalink
Merge pull request #38 from bobanetwork/fix-pending-block
Browse files Browse the repository at this point in the history
Serve the latest block as pending block
  • Loading branch information
boyuan-chen authored Aug 9, 2023
2 parents 6f27aba + bf798aa commit fb51c3a
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit fb51c3a

Please sign in to comment.