mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +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,15 +23,17 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, hash common.Hash)
|
||||
return nil, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
chainConfig, err := api.chainConfig(tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// https://infura.io/docs/ethereum/json-rpc/eth-getTransactionByHash
|
||||
blockNum, ok, err := api.txnLookup(ctx, tx, hash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
if ok {
|
||||
block, err := api.blockByNumberWithSenders(tx, blockNum)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -52,10 +54,6 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, hash common.Hash)
|
||||
|
||||
// Add GasPrice for the DynamicFeeTransaction
|
||||
var baseFee *big.Int
|
||||
chainConfig, err := api.chainConfig(tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if chainConfig.IsLondon(blockNum) && blockHash != (common.Hash{}) {
|
||||
baseFee = block.BaseFee()
|
||||
}
|
||||
@ -63,6 +61,8 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, hash common.Hash)
|
||||
if txn != nil {
|
||||
return newRPCTransaction(txn, blockHash, blockNum, txnIndex, baseFee), nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
curHeader := rawdb.ReadCurrentHeader(tx)
|
||||
if curHeader == nil {
|
||||
@ -76,7 +76,7 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, hash common.Hash)
|
||||
}
|
||||
if len(reply.RlpTxs[0]) > 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 {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user