MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / GetTransaction

Function GetTransaction

src/main.cpp:327–356  ·  view source on GitHub ↗

Return transaction in tx, and if it was found inside a block, its hash is placed in blockHash

Source from the content-addressed store, hash-verified

325
326// Return transaction in tx, and if it was found inside a block, its hash is placed in blockHash
327bool GetTransaction(std::shared_ptr<CBaseTx> &pBaseTx, const uint256 &hash, CBlockDBCache &blockCache,
328 bool bSearchMemPool) {
329 {
330 LOCK(cs_main);
331 {
332 if (bSearchMemPool == true) {
333 pBaseTx = mempool.Lookup(hash);
334 if (pBaseTx.get())
335 return true;
336 }
337 }
338
339 if (SysCfg().IsTxIndex()) {
340 CDiskTxPos diskTxPos;
341 if (blockCache.ReadTxIndex(hash, diskTxPos)) {
342 CAutoFile file(OpenBlockFile(diskTxPos, true), SER_DISK, CLIENT_VERSION);
343 CBlockHeader header;
344 try {
345 file >> header;
346 fseek(file, diskTxPos.nTxOffset, SEEK_CUR);
347 file >> pBaseTx;
348 } catch (std::exception &e) {
349 return ERRORMSG("Deserialize or I/O error - %s", e.what());
350 }
351 return true;
352 }
353 }
354 }
355 return false;
356}
357
358uint256 GetOrphanRoot(const uint256 &hash) {
359 map<uint256, COrphanBlock *>::iterator it = mapOrphanBlocks.find(hash);

Callers 2

ExGetTxContractFuncFunction · 0.85
ExGetTxRegIDFuncFunction · 0.85

Calls 6

OpenBlockFileFunction · 0.85
IsTxIndexMethod · 0.80
ReadTxIndexMethod · 0.80
LookupMethod · 0.45
getMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected