aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-07-31 17:55:05 +0200
committerPeter Todd <pete@petertodd.org>2015-10-02 12:27:20 +0200
commit5094a81d3b920283333623b49ac382d0b545642e (patch)
treea27ba09a751d627fd01b399adfc9cedc9cefea39 /src
parentec9b6c33e813021948c53356173e313b43b03c13 (diff)
downloadbitcoin-5094a81d3b920283333623b49ac382d0b545642e.tar.xz
Move recentRejects initialization to top of InitBlockIndex
This avoids that premature return in the condition that a new chain is initialized results in NULL pointer errors due to recentReject not being constructed. Also add assertions where it is used. (cherry picked from commit a8d0407c4fcf7c4e8ed0e8edabd204f7a4efa477)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index eeec0097d8..cb41afc96b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3404,6 +3404,10 @@ bool LoadBlockIndex()
bool InitBlockIndex() {
const CChainParams& chainparams = Params();
LOCK(cs_main);
+
+ // Initialize global variables that cannot be constructed at startup.
+ recentRejects.reset(new CRollingBloomFilter(120000, 0.000001));
+
// Check whether we're already initialized
if (chainActive.Genesis() != NULL)
return true;
@@ -3437,9 +3441,6 @@ bool InitBlockIndex() {
}
}
- // Initialize global variables that cannot be constructed at startup.
- recentRejects.reset(new CRollingBloomFilter(120000, 0.000001));
-
return true;
}
@@ -3809,6 +3810,7 @@ bool static AlreadyHave(const CInv& inv)
{
case MSG_TX:
{
+ assert(recentRejects);
if (chainActive.Tip()->GetBlockHash() != hashRecentRejectsChainTip)
{
// If the chain tip has changed previously rejected transactions
@@ -4422,6 +4424,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// Probably non-standard or insufficient fee/priority
LogPrint("mempool", " removed orphan tx %s\n", orphanHash.ToString());
vEraseQueue.push_back(orphanHash);
+ assert(recentRejects);
recentRejects->insert(orphanHash);
}
mempool.check(pcoinsTip);
@@ -4445,6 +4448,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// already in the mempool; if the tx isn't in the mempool that
// means it was rejected and we shouldn't ask for it again.
if (!mempool.exists(tx.GetHash())) {
+ assert(recentRejects);
recentRejects->insert(tx.GetHash());
}
if (pfrom->fWhitelisted) {