aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-11-06 12:24:37 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-11-06 14:08:06 +0100
commit6c31ac019f1b2b5181884de742317efda706e2f0 (patch)
tree88206ecfb792e93fd346432e7ee7ae6f6a7c5280 /src/main.cpp
parentdf616ae43ed4d9227f0b52b09ebe4e9eb4bb49cf (diff)
parentaf6edac0bd637c07a9eb2cbb0dd1498b3593f801 (diff)
downloadbitcoin-6c31ac019f1b2b5181884de742317efda706e2f0.tar.xz
Merge pull request #6825
af6edac *: alias -h for --help (Daniel Cousens) 131d7f9 Change URLs to https in debian/control (Matt Corallo) 7ce2c91 Update debian/changelog and slight tweak to debian/control (Matt Corallo) 4fbfebe Correct spelling mistakes in doc folder (Mitchell Cash) e42bf16 Clarification of unit test build instructions. (Eric Lombrozo) 54f9dee Update bluematt-key, the old one is long-since revoked (Matt Corallo) bfc6154 [Trivial] Fixed typo when referring to a previous section in depends/README.md [skip ci] (Chris Kleeschulte) 9e45157 build: disable -Wself-assign (Wladimir J. van der Laan) 33d6825 Bugfix: Allow mining on top of old tip blocks for testnet (fixes testnet-in-a-box use case) (Luke Dashjr) 87a797a build: Remove dependency of bitcoin-cli on secp256k1 (Wladimir J. van der Laan) a33cd5b [trivial] Fix rpc message "help generate" (MarcoFalke) 6fd0019 Drop "with minimal dependencies" from description (Zak Wilcox) 2394f4d Split bitcoin-tx into its own package (Zak Wilcox) 1e672ae Include bitcoin-tx binary on Debian/Ubuntu (Zak Wilcox) b3eaa30 [Qt] Raise debug window when requested (MarcoFalke) 01878c9 Fix locking in GetTransaction. (Alex Morcos) 9b9acc2 Fix spelling of Qt (Diego Viola)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp70
1 files changed, 34 insertions, 36 deletions
diff --git a/src/main.cpp b/src/main.cpp
index af907d06bc..98e4344094 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1116,47 +1116,45 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
{
CBlockIndex *pindexSlow = NULL;
+
+ LOCK(cs_main);
+
+ if (mempool.lookup(hash, txOut))
{
- LOCK(cs_main);
- {
- if (mempool.lookup(hash, txOut))
- {
- return true;
- }
- }
+ 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 (const 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;
+ 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 (const 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;
}
+ }
- if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it
- int nHeight = -1;
- {
- CCoinsViewCache &view = *pcoinsTip;
- const CCoins* coins = view.AccessCoins(hash);
- if (coins)
- nHeight = coins->nHeight;
- }
- if (nHeight > 0)
- pindexSlow = chainActive[nHeight];
+ if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it
+ int nHeight = -1;
+ {
+ CCoinsViewCache &view = *pcoinsTip;
+ const CCoins* coins = view.AccessCoins(hash);
+ if (coins)
+ nHeight = coins->nHeight;
}
+ if (nHeight > 0)
+ pindexSlow = chainActive[nHeight];
}
if (pindexSlow) {
@@ -1265,7 +1263,7 @@ bool IsInitialBlockDownload()
if (lockIBDState)
return false;
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
- pindexBestHeader->GetBlockTime() < GetTime() - 24 * 60 * 60);
+ pindexBestHeader->GetBlockTime() < GetTime() - chainParams.MaxTipAge());
if (!state)
lockIBDState = true;
return state;