Changeset View
Changeset View
Standalone View
Standalone View
src/policy/fees.cpp
Show First 20 Lines • Show All 337 Lines • ▼ Show 20 Lines | |||||
CBlockPolicyEstimator::CBlockPolicyEstimator(const CFeeRate &_minRelayFee) | CBlockPolicyEstimator::CBlockPolicyEstimator(const CFeeRate &_minRelayFee) | ||||
: nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0) { | : nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0) { | ||||
static_assert(MIN_FEERATE > 0, "Min feerate must be nonzero"); | static_assert(MIN_FEERATE > 0, "Min feerate must be nonzero"); | ||||
minTrackedFee = _minRelayFee < CFeeRate(Amount(int64_t(MIN_FEERATE))) | minTrackedFee = _minRelayFee < CFeeRate(Amount(int64_t(MIN_FEERATE))) | ||||
? CFeeRate(Amount(int64_t(MIN_FEERATE))) | ? CFeeRate(Amount(int64_t(MIN_FEERATE))) | ||||
: _minRelayFee; | : _minRelayFee; | ||||
std::vector<double> vfeelist; | std::vector<double> vfeelist; | ||||
for (double bucketBoundary = minTrackedFee.GetFeePerK().GetSatoshis(); | for (Amount bucketBoundary = minTrackedFee.GetFeePerK(); | ||||
bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) { | bucketBoundary <= MAX_FEERATE; | ||||
vfeelist.push_back(bucketBoundary); | bucketBoundary += bucketBoundary / FEE_SPACING_FRACTION) { | ||||
vfeelist.push_back(double(bucketBoundary.GetSatoshis())); | |||||
deadalnix: The semantic of that code has changed. | |||||
} | } | ||||
vfeelist.push_back(INF_FEERATE); | vfeelist.push_back(double(INF_FEERATE.GetSatoshis())); | ||||
feeStats.Initialize(vfeelist, MAX_BLOCK_CONFIRMS, DEFAULT_DECAY); | feeStats.Initialize(vfeelist, MAX_BLOCK_CONFIRMS, DEFAULT_DECAY); | ||||
} | } | ||||
void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry &entry, | void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry &entry, | ||||
bool validFeeEstimate) { | bool validFeeEstimate) { | ||||
uint32_t txHeight = entry.GetHeight(); | uint32_t txHeight = entry.GetHeight(); | ||||
uint256 txid = entry.GetTx().GetId(); | uint256 txid = entry.GetTx().GetId(); | ||||
if (mapMemPoolTxs.count(txid)) { | if (mapMemPoolTxs.count(txid)) { | ||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | double CBlockPolicyEstimator::estimateSmartPriority(int confTarget, | ||||
} | } | ||||
// If mempool is limiting txs, no priority txs are allowed | // If mempool is limiting txs, no priority txs are allowed | ||||
Amount minPoolFee = | Amount minPoolFee = | ||||
pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | ||||
1000000) | 1000000) | ||||
.GetFeePerK(); | .GetFeePerK(); | ||||
if (minPoolFee > 0) { | if (minPoolFee > 0) { | ||||
return INF_PRIORITY; | return double(INF_PRIORITY.GetSatoshis()); | ||||
} | } | ||||
return -1; | return -1; | ||||
} | } | ||||
void CBlockPolicyEstimator::Write(CAutoFile &fileout) { | void CBlockPolicyEstimator::Write(CAutoFile &fileout) { | ||||
fileout << nBestSeenHeight; | fileout << nBestSeenHeight; | ||||
feeStats.Write(fileout); | feeStats.Write(fileout); | ||||
} | } | ||||
void CBlockPolicyEstimator::Read(CAutoFile &filein, int nFileVersion) { | void CBlockPolicyEstimator::Read(CAutoFile &filein, int nFileVersion) { | ||||
int nFileBestSeenHeight; | int nFileBestSeenHeight; | ||||
filein >> nFileBestSeenHeight; | filein >> nFileBestSeenHeight; | ||||
feeStats.Read(filein); | feeStats.Read(filein); | ||||
nBestSeenHeight = nFileBestSeenHeight; | nBestSeenHeight = nFileBestSeenHeight; | ||||
if (nFileVersion < 139900) { | if (nFileVersion < 139900) { | ||||
TxConfirmStats priStats; | TxConfirmStats priStats; | ||||
priStats.Read(filein); | priStats.Read(filein); | ||||
} | } | ||||
} | } | ||||
FeeFilterRounder::FeeFilterRounder(const CFeeRate &minIncrementalFee) { | FeeFilterRounder::FeeFilterRounder(const CFeeRate &minIncrementalFee) { | ||||
Amount minFeeLimit = | Amount minFeeLimit = | ||||
std::max(Amount(1), minIncrementalFee.GetFeePerK() / 2); | std::max(Amount(1), minIncrementalFee.GetFeePerK() / 2); | ||||
feeset.insert(0); | feeset.insert(Amount(0)); | ||||
for (double bucketBoundary = minFeeLimit.GetSatoshis(); | for (Amount bucketBoundary = minFeeLimit; bucketBoundary <= MAX_FEERATE; | ||||
bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) { | bucketBoundary += bucketBoundary / FEE_SPACING_FRACTION) { | ||||
deadalnixUnsubmitted Not Done Inline Actionsdito deadalnix: dito | |||||
feeset.insert(bucketBoundary); | feeset.insert(bucketBoundary); | ||||
} | } | ||||
} | } | ||||
CAmount FeeFilterRounder::round(CAmount currentMinFee) { | Amount FeeFilterRounder::round(const Amount currentMinFee) { | ||||
std::set<double>::iterator it = feeset.lower_bound(currentMinFee); | std::set<Amount>::iterator it = feeset.lower_bound(currentMinFee); | ||||
if ((it != feeset.begin() && insecure_rand.rand32() % 3 != 0) || | if ((it != feeset.begin() && insecure_rand.rand32() % 3 != 0) || | ||||
it == feeset.end()) { | it == feeset.end()) { | ||||
it--; | it--; | ||||
} | } | ||||
return *it; | return *it; | ||||
} | } |
The semantic of that code has changed.