Browse Source

Closes #3134 - Least Authority Issue E

CTxMemPool::check() does nothing when turned on, due to overflow.
pull/4/head
Simon 6 years ago
parent
commit
a0c977ca61
  1. 10
      src/test/mempool_tests.cpp
  2. 7
      src/txmempool.h

10
src/test/mempool_tests.cpp

@ -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
src/txmempool.h

@ -161,7 +161,7 @@ public:
* 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);
@ -219,6 +219,11 @@ public:
bool ReadFeeEstimates(CAutoFile& filein);
size_t DynamicMemoryUsage() const;
/** Return nCheckFrequency */
uint32_t GetCheckFrequency() const {
return nCheckFrequency;
}
};
/**

Loading…
Cancel
Save