MCPcopy Create free account
hub / github.com/CPChain/chain / GetTransactionByHash

Method GetTransactionByHash

internal/cpcapi/api.go:1258–1269  ·  view source on GitHub ↗

GetTransactionByHash returns the transaction for the given hash

(ctx context.Context, hash common.Hash)

Source from the content-addressed store, hash-verified

1256
1257// GetTransactionByHash returns the transaction for the given hash
1258func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) *RPCTransaction {
1259 // Try to return an already finalized transaction
1260 if tx, blockHash, blockNumber, index := rawdb.ReadTransaction(s.b.ChainDb(), hash); tx != nil {
1261 return newRPCTransaction(tx, blockHash, blockNumber, index)
1262 }
1263 // No finalized transaction, try to retrieve it from the pool
1264 if tx := s.b.GetPoolTransaction(hash); tx != nil {
1265 return newRPCPendingTransaction(tx)
1266 }
1267 // Transaction unknown, return as such
1268 return nil
1269}
1270
1271// GetRawTransactionByHash returns the bytes of the transaction for the given hash.
1272func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) {

Callers

nothing calls this directly

Calls 4

newRPCTransactionFunction · 0.85
newRPCPendingTransactionFunction · 0.85
ChainDbMethod · 0.65
GetPoolTransactionMethod · 0.65

Tested by

no test coverage detected