From 0c21432f02cea6dbeceef9f9c71226006beded68 Mon Sep 17 00:00:00 2001 From: Ubuntu 64 Date: Thu, 28 Dec 2017 00:06:13 +0900 Subject: [PATCH] third commit --- src/main.cpp | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) mode change 100755 => 100644 src/main.cpp diff --git a/src/main.cpp b/src/main.cpp old mode 100755 new mode 100644 index 59b40d9f..3f40324b --- a/src/main.cpp +++ b/src/main.cpp @@ -1045,33 +1045,31 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock { CBlockIndex *pindexSlow = NULL; - LOCK(cs_main); - - if (mempool.lookup(hash, txOut)) - { - return true; - } + LOCK(cs_main); + + if (mempool.lookup(hash, txOut)) + { + return true; + } - if (fTxIndex) { - CDiskTxPos postx; - if (pblocktree->ReadTxIndex(hash, postx)) { - CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION); - if (file.IsNull()) - return error("%s: OpenBlockFile failed", __func__); - CBlockHeader header; - try { - file >> header; - fseek(file.Get(), postx.nTxOffset, SEEK_CUR); - file >> txOut; - } catch (std::exception &e) { - return error("%s : Deserialize or I/O error - %s", __func__, e.what()); + if (fTxIndex) { + CDiskTxPos postx; + if (pblocktree->ReadTxIndex(hash, postx)) { + CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION); + CBlockHeader header; + try { + file >> header; + fseek(file, postx.nTxOffset, SEEK_CUR); + file >> txOut; + } catch (std::exception &e) { + return error("%s : Deserialize or I/O error - %s", __func__, e.what()); + } + hashBlock = header.GetHash(); + if (txOut.GetHash() != hash) + return error("%s : txid mismatch", __func__); + return true; } - hashBlock = header.GetHash(); - if (txOut.GetHash() != hash) - return error("%s : txid mismatch", __func__); - return true; } - } if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it int nHeight = -1; @@ -1084,7 +1082,6 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock if (nHeight > 0) pindexSlow = chainActive[nHeight]; } - } if (pindexSlow) { CBlock block;