aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2014-07-03 14:25:32 -0400
committerGavin Andresen <gavinandresen@gmail.com>2014-07-03 14:42:16 -0400
commit13fc83c77bb9108c00dd7709ce17719edb763273 (patch)
tree4d9397d208b3c74bea11056ec9402fdfc81a36f5 /src/txmempool.cpp
parent4b7b1bb1ac54e067d889170757a8c45f0baaae3d (diff)
downloadbitcoin-13fc83c77bb9108c00dd7709ce17719edb763273.tar.xz
Move fee policy out of core
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 0a8ad96aac..a852de5da8 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -80,13 +80,13 @@ public:
// Used as belt-and-suspenders check when reading to detect
// file corruption
- bool AreSane(const std::vector<CFeeRate>& vecFee)
+ bool AreSane(const std::vector<CFeeRate>& vecFee, const CFeeRate& minRelayFee)
{
BOOST_FOREACH(CFeeRate fee, vecFee)
{
if (fee < CFeeRate(0))
return false;
- if (fee.GetFee(1000) > CTransaction::minRelayTxFee.GetFee(1000) * 10000)
+ if (fee.GetFeePerK() > minRelayFee.GetFeePerK() * 10000)
return false;
}
return true;
@@ -109,10 +109,10 @@ public:
fileout << vecPriority;
}
- void Read(CAutoFile& filein) {
+ void Read(CAutoFile& filein, const CFeeRate& minRelayFee) {
std::vector<CFeeRate> vecFee;
filein >> vecFee;
- if (AreSane(vecFee))
+ if (AreSane(vecFee, minRelayFee))
feeSamples.insert(feeSamples.end(), vecFee.begin(), vecFee.end());
else
throw runtime_error("Corrupt fee value in estimates file.");
@@ -141,7 +141,7 @@ private:
// nBlocksAgo is 0 based, i.e. transactions that confirmed in the highest seen block are
// nBlocksAgo == 0, transactions in the block before that are nBlocksAgo == 1 etc.
- void seenTxConfirm(CFeeRate feeRate, double dPriority, int nBlocksAgo)
+ void seenTxConfirm(const CFeeRate& feeRate, const CFeeRate& minRelayFee, double dPriority, int nBlocksAgo)
{
// Last entry records "everything else".
int nBlocksTruncated = min(nBlocksAgo, (int) history.size() - 1);
@@ -149,7 +149,7 @@ private:
// We need to guess why the transaction was included in a block-- either
// because it is high-priority or because it has sufficient fees.
- bool sufficientFee = (feeRate > CTransaction::minRelayTxFee);
+ bool sufficientFee = (feeRate > minRelayFee);
bool sufficientPriority = AllowFree(dPriority);
const char* assignedTo = "unassigned";
if (sufficientFee && !sufficientPriority)
@@ -177,7 +177,7 @@ public:
history.resize(nEntries);
}
- void seenBlock(const std::vector<CTxMemPoolEntry>& entries, int nBlockHeight)
+ void seenBlock(const std::vector<CTxMemPoolEntry>& entries, int nBlockHeight, const CFeeRate minRelayFee)
{
if (nBlockHeight <= nBestSeenHeight)
{
@@ -222,7 +222,7 @@ public:
// Fees are stored and reported as BTC-per-kb:
CFeeRate feeRate(entry->GetFee(), entry->GetTxSize());
double dPriority = entry->GetPriority(entry->GetHeight()); // Want priority when it went IN
- seenTxConfirm(feeRate, dPriority, i);
+ seenTxConfirm(feeRate, minRelayFee, dPriority, i);
}
}
for (size_t i = 0; i < history.size(); i++) {
@@ -313,7 +313,7 @@ public:
}
}
- void Read(CAutoFile& filein)
+ void Read(CAutoFile& filein, const CFeeRate& minRelayFee)
{
filein >> nBestSeenHeight;
size_t numEntries;
@@ -322,14 +322,14 @@ public:
for (size_t i = 0; i < numEntries; i++)
{
CBlockAverage entry;
- entry.Read(filein);
+ entry.Read(filein, minRelayFee);
history.push_back(entry);
}
}
};
-CTxMemPool::CTxMemPool()
+CTxMemPool::CTxMemPool(const CFeeRate& _minRelayFee) : minRelayFee(_minRelayFee)
{
// Sanity checks off by default for performance, because otherwise
// accepting transactions becomes O(N^2) where N is the number
@@ -445,7 +445,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned i
if (mapTx.count(hash))
entries.push_back(mapTx[hash]);
}
- minerPolicyEstimator->seenBlock(entries, nBlockHeight);
+ minerPolicyEstimator->seenBlock(entries, nBlockHeight, minRelayFee);
BOOST_FOREACH(const CTransaction& tx, vtx)
{
std::list<CTransaction> dummy;
@@ -560,7 +560,7 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein)
return error("CTxMemPool::ReadFeeEstimates() : up-version (%d) fee estimate file", nVersionRequired);
LOCK(cs);
- minerPolicyEstimator->Read(filein);
+ minerPolicyEstimator->Read(filein, minRelayFee);
}
catch (std::exception &e) {
LogPrintf("CTxMemPool::ReadFeeEstimates() : unable to read policy estimator data (non-fatal)");