Skip to content

Commit

Permalink
third commit
Browse files Browse the repository at this point in the history
  • Loading branch information
conan-equal-newone committed Dec 27, 2017
1 parent 1b4b6c8 commit 0c21432
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions src/main.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -1084,7 +1082,6 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
if (nHeight > 0)
pindexSlow = chainActive[nHeight];
}
}

if (pindexSlow) {
CBlock block;
Expand Down

0 comments on commit 0c21432

Please sign in to comment.