Fix compatibility of eth_getBlockTransactionCountByHash (#5297)

* fix compatibility of eth_getBlockTransactionCountByHash

* fixup
This commit is contained in:
Igor Mandrigin 2022-09-07 07:11:48 +02:00 committed by GitHub
parent e2301387eb
commit a0c80ccbee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -336,7 +336,9 @@ func (api *APIImpl) GetBlockTransactionCountByHash(ctx context.Context, blockHas
defer tx.Rollback()
blockNum, _, _, err := rpchelper.GetBlockNumber(rpc.BlockNumberOrHash{BlockHash: &blockHash}, tx, nil)
if err != nil {
return nil, err
// (Compatibility) Every other node just return `null` for when the block does not exist.
log.Debug("eth_getBlockTransactionCountByHash GetBlockNumber failed", "err", err)
return nil, nil
}
_, txAmount, err := api._blockReader.Body(ctx, tx, blockHash, blockNum)
if err != nil {