Return transaction in tx, and if it was found inside a block, its hash is placed in blockHash
| 325 | |
| 326 | // Return transaction in tx, and if it was found inside a block, its hash is placed in blockHash |
| 327 | bool 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 | |
| 358 | uint256 GetOrphanRoot(const uint256 &hash) { |
| 359 | map<uint256, COrphanBlock *>::iterator it = mapOrphanBlocks.find(hash); |
no test coverage detected