Skip to content

Commit

Permalink
Merge pull request #5481
Browse files Browse the repository at this point in the history
6484930 Apply AreSane() checks to the fees from the network. (Gregory Maxwell)
  • Loading branch information
laanwj committed Dec 23, 2014
2 parents d01bcc4 + 6484930 commit 055f3ae
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/txmempool.cpp
Expand Up @@ -91,22 +91,32 @@ class CBlockAverage
* 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;
Expand Down Expand Up @@ -167,12 +177,12 @@ class CMinerPolicyEstimator
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";
Expand Down

0 comments on commit 055f3ae

Please sign in to comment.