Skip to content

Commit 055f3ae

Browse files
committed
Merge pull request #5481
6484930 Apply AreSane() checks to the fees from the network. (Gregory Maxwell)
2 parents d01bcc4 + 6484930 commit 055f3ae

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/txmempool.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,32 @@ class CBlockAverage
9191
* Used as belt-and-suspenders check when reading to detect
9292
* file corruption
9393
*/
94-
bool AreSane(const std::vector<CFeeRate>& vecFee, const CFeeRate& minRelayFee)
94+
static bool AreSane(const CFeeRate fee, const CFeeRate& minRelayFee)
95+
{
96+
if (fee < CFeeRate(0))
97+
return false;
98+
if (fee.GetFeePerK() > minRelayFee.GetFeePerK() * 10000)
99+
return false;
100+
return true;
101+
}
102+
static bool AreSane(const std::vector<CFeeRate>& vecFee, const CFeeRate& minRelayFee)
95103
{
96104
BOOST_FOREACH(CFeeRate fee, vecFee)
97105
{
98-
if (fee < CFeeRate(0))
99-
return false;
100-
if (fee.GetFeePerK() > minRelayFee.GetFeePerK() * 10000)
106+
if (!AreSane(fee, minRelayFee))
101107
return false;
102108
}
103109
return true;
104110
}
105-
bool AreSane(const std::vector<double> vecPriority)
111+
static bool AreSane(const double priority)
112+
{
113+
return priority >= 0;
114+
}
115+
static bool AreSane(const std::vector<double> vecPriority)
106116
{
107117
BOOST_FOREACH(double priority, vecPriority)
108118
{
109-
if (priority < 0)
119+
if (!AreSane(priority))
110120
return false;
111121
}
112122
return true;
@@ -167,12 +177,12 @@ class CMinerPolicyEstimator
167177
bool sufficientFee = (feeRate > minRelayFee);
168178
bool sufficientPriority = AllowFree(dPriority);
169179
const char* assignedTo = "unassigned";
170-
if (sufficientFee && !sufficientPriority)
180+
if (sufficientFee && !sufficientPriority && CBlockAverage::AreSane(feeRate, minRelayFee))
171181
{
172182
history[nBlocksTruncated].RecordFee(feeRate);
173183
assignedTo = "fee";
174184
}
175-
else if (sufficientPriority && !sufficientFee)
185+
else if (sufficientPriority && !sufficientFee && CBlockAverage::AreSane(dPriority))
176186
{
177187
history[nBlocksTruncated].RecordPriority(dPriority);
178188
assignedTo = "priority";

0 commit comments

Comments
 (0)