mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-11 05:20:05 +00:00
GetTransactionByHash: fallback to txpool (#3463)
* GetTransactionByHash: fallback to txpool * GetTransactionByHash: fallback to txpool
This commit is contained in:
parent
2e17b8f515
commit
ccf434f270
@ -23,45 +23,45 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, hash common.Hash)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer tx.Rollback()
|
||||||
|
chainConfig, err := api.chainConfig(tx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// https://infura.io/docs/ethereum/json-rpc/eth-getTransactionByHash
|
// https://infura.io/docs/ethereum/json-rpc/eth-getTransactionByHash
|
||||||
blockNum, ok, err := api.txnLookup(ctx, tx, hash)
|
blockNum, ok, err := api.txnLookup(ctx, tx, hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !ok {
|
if ok {
|
||||||
return nil, nil
|
block, err := api.blockByNumberWithSenders(tx, blockNum)
|
||||||
}
|
if err != nil {
|
||||||
block, err := api.blockByNumberWithSenders(tx, blockNum)
|
return nil, err
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
if block == nil {
|
||||||
}
|
return nil, nil
|
||||||
if block == nil {
|
}
|
||||||
return nil, nil
|
blockHash := block.Hash()
|
||||||
}
|
var txnIndex uint64
|
||||||
blockHash := block.Hash()
|
var txn types2.Transaction
|
||||||
var txnIndex uint64
|
for i, transaction := range block.Transactions() {
|
||||||
var txn types2.Transaction
|
if transaction.Hash() == hash {
|
||||||
for i, transaction := range block.Transactions() {
|
txn = transaction
|
||||||
if transaction.Hash() == hash {
|
txnIndex = uint64(i)
|
||||||
txn = transaction
|
break
|
||||||
txnIndex = uint64(i)
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Add GasPrice for the DynamicFeeTransaction
|
// Add GasPrice for the DynamicFeeTransaction
|
||||||
var baseFee *big.Int
|
var baseFee *big.Int
|
||||||
chainConfig, err := api.chainConfig(tx)
|
if chainConfig.IsLondon(blockNum) && blockHash != (common.Hash{}) {
|
||||||
if err != nil {
|
baseFee = block.BaseFee()
|
||||||
return nil, err
|
}
|
||||||
}
|
|
||||||
if chainConfig.IsLondon(blockNum) && blockHash != (common.Hash{}) {
|
|
||||||
baseFee = block.BaseFee()
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn != nil {
|
if txn != nil {
|
||||||
return newRPCTransaction(txn, blockHash, blockNum, txnIndex, baseFee), nil
|
return newRPCTransaction(txn, blockHash, blockNum, txnIndex, baseFee), nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
curHeader := rawdb.ReadCurrentHeader(tx)
|
curHeader := rawdb.ReadCurrentHeader(tx)
|
||||||
@ -76,7 +76,7 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, hash common.Hash)
|
|||||||
}
|
}
|
||||||
if len(reply.RlpTxs[0]) > 0 {
|
if len(reply.RlpTxs[0]) > 0 {
|
||||||
s := rlp.NewStream(bytes.NewReader(reply.RlpTxs[0]), uint64(len(reply.RlpTxs[0])))
|
s := rlp.NewStream(bytes.NewReader(reply.RlpTxs[0]), uint64(len(reply.RlpTxs[0])))
|
||||||
txn, err = types2.DecodeTransaction(s)
|
txn, err := types2.DecodeTransaction(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user