Apply AreSane() checks to the fees from the network.
'Sane' was already defined by this code as: fee.GetFeePerK() > minRelayFee.GetFeePerK() * 10000 But sanity was only enforced for data loaded from disk. Note that this is a pretty expansive definition of 'sane': A 10 BTC fee is still passes the test if its on a 100kb transaction. This prevents a single insane fee on the network from making us reject our stored fee data at start. We still may reject valid saved fee state if minRelayFee is changed between executions. This also reduces the risk and limits the damage from a cascading failure where one party pays a bunch of insane fees which cases others to pay insane fees.
This commit is contained in:
parent
13c077c7cf
commit
6484930690
1 changed files with 18 additions and 8 deletions
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue