mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 04:03:49 +00:00
fix compatibility of getting tx by number (#3409)
* fix compatibility of getting tx by number `eth_getTransactionByBlockHashAndIndex` and `eth_getTransactionByBlockNumberAndIndex` should return `null` if the index provided is out of bound (checked with Infura and Cloudflare ETH gateway). * small fixup (formatting)
This commit is contained in:
parent
e23f23757f
commit
ff4fa5efd3
@ -3,7 +3,6 @@ package commands
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces"
|
||||
@ -161,7 +160,7 @@ func (api *APIImpl) GetTransactionByBlockHashAndIndex(ctx context.Context, block
|
||||
|
||||
txs := block.Transactions()
|
||||
if uint64(txIndex) >= uint64(len(txs)) {
|
||||
return nil, fmt.Errorf("txIndex (%d) out of range (nTxs: %d)", uint64(txIndex), uint64(len(txs)))
|
||||
return nil, nil // not error
|
||||
}
|
||||
|
||||
return newRPCTransaction(txs[txIndex], block.Hash(), block.NumberU64(), uint64(txIndex), block.BaseFee()), nil
|
||||
@ -211,7 +210,7 @@ func (api *APIImpl) GetTransactionByBlockNumberAndIndex(ctx context.Context, blo
|
||||
|
||||
txs := block.Transactions()
|
||||
if uint64(txIndex) >= uint64(len(txs)) {
|
||||
return nil, fmt.Errorf("txIndex (%d) out of range (nTxs: %d)", uint64(txIndex), uint64(len(txs)))
|
||||
return nil, nil // not error
|
||||
}
|
||||
|
||||
return newRPCTransaction(txs[txIndex], block.Hash(), block.NumberU64(), uint64(txIndex), block.BaseFee()), nil
|
||||
|
Loading…
Reference in New Issue
Block a user