diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-23 12:28:20 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-23 12:29:33 +0100 |
commit | 055f3ae9aaab8731b34d1731a0b26b3527301c01 (patch) | |
tree | 0196750dfcefa8a3c824c99e611948a34b282cbe /src/txmempool.cpp | |
parent | d01bcc446ea969b5213b8795566bd6d88f288545 (diff) | |
parent | 64849306905e625fd44d297e8d58c3e1dd98cb90 (diff) |
Merge pull request #5481
6484930 Apply AreSane() checks to the fees from the network. (Gregory Maxwell)
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 40d24d3b78..3071ab025c 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -91,22 +91,32 @@ public: * Used as belt-and-suspenders check when reading to detect * file corruption */ - bool AreSane(const std::vector<CFeeRate>& vecFee, const CFeeRate& minRelayFee) + static bool AreSane(const CFeeRate fee, const CFeeRate& minRelayFee) + { + if (fee < CFeeRate(0)) + return false; + if (fee.GetFeePerK() > minRelayFee.GetFeePerK() * 10000) + return false; + return true; + } + static bool AreSane(const std::vector<CFeeRate>& vecFee, const CFeeRate& minRelayFee) { BOOST_FOREACH(CFeeRate fee, vecFee) { - if (fee < CFeeRate(0)) - return false; - if (fee.GetFeePerK() > minRelayFee.GetFeePerK() * 10000) + if (!AreSane(fee, minRelayFee)) return false; } return true; } - bool AreSane(const std::vector<double> vecPriority) + static bool AreSane(const double priority) + { + return priority >= 0; + } + static bool AreSane(const std::vector<double> vecPriority) { BOOST_FOREACH(double priority, vecPriority) { - if (priority < 0) + if (!AreSane(priority)) return false; } return true; @@ -167,12 +177,12 @@ private: bool sufficientFee = (feeRate > minRelayFee); bool sufficientPriority = AllowFree(dPriority); const char* assignedTo = "unassigned"; - if (sufficientFee && !sufficientPriority) + if (sufficientFee && !sufficientPriority && CBlockAverage::AreSane(feeRate, minRelayFee)) { history[nBlocksTruncated].RecordFee(feeRate); assignedTo = "fee"; } - else if (sufficientPriority && !sufficientFee) + else if (sufficientPriority && !sufficientFee && CBlockAverage::AreSane(dPriority)) { history[nBlocksTruncated].RecordPriority(dPriority); assignedTo = "priority"; |