Skip to content

Commit

Permalink
Closes zcash#3134 - Least Authority Issue E
Browse files Browse the repository at this point in the history
CTxMemPool::check() does nothing when turned on, due to overflow.
  • Loading branch information
bitcartel committed Apr 11, 2018
1 parent 079d9e6 commit a0c977c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/test/mempool_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,14 @@ BOOST_AUTO_TEST_CASE(RemoveWithoutBranchId) {
BOOST_CHECK_EQUAL(pool.size(), 0);
}

// Test that nCheckFrequency is set correctly when calling setSanityCheck().
// https://github.com/zcash/zcash/issues/3134
BOOST_AUTO_TEST_CASE(SetSanityCheck) {
CTxMemPool pool(CFeeRate(0));
pool.setSanityCheck(1.0);
BOOST_CHECK_EQUAL(pool.GetCheckFrequency(), 4294967295);
pool.setSanityCheck(0);
BOOST_CHECK_EQUAL(pool.GetCheckFrequency(), 0);
}

BOOST_AUTO_TEST_SUITE_END()
7 changes: 6 additions & 1 deletion src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class CTxMemPool
* check does nothing.
*/
void check(const CCoinsViewCache *pcoins) const;
void setSanityCheck(double dFrequency = 1.0) { nCheckFrequency = dFrequency * 4294967296.0; }
void setSanityCheck(double dFrequency = 1.0) { nCheckFrequency = static_cast<uint32_t>(dFrequency * 4294967295.0); }

bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, bool fCurrentEstimate = true);
void remove(const CTransaction &tx, std::list<CTransaction>& removed, bool fRecursive = false);
Expand Down Expand Up @@ -219,6 +219,11 @@ class CTxMemPool
bool ReadFeeEstimates(CAutoFile& filein);

size_t DynamicMemoryUsage() const;

/** Return nCheckFrequency */
uint32_t GetCheckFrequency() const {
return nCheckFrequency;
}
};

/**
Expand Down

0 comments on commit a0c977c

Please sign in to comment.