diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -22,6 +22,8 @@ #include +#include + CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef &_tx, const Amount _nFee, int64_t _nTime, double _entryPriority, unsigned int _entryHeight, @@ -964,13 +966,33 @@ CFeeRate CTxMemPool::estimateFee(int nBlocks) const { LOCK(cs); - return minerPolicyEstimator->estimateFee(nBlocks); + + uint64_t maxMempoolSize = + gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; + // minerPolicy uses recent blocks to figure out a reasonable fee. This may + // disagree + // with the rollingMinimumFeerate under certain scenarios where the blocks + // include low fee + // transactions, but the mempool is being spammed. + // Therefore, use the maximum of the two values. + return std::max(minerPolicyEstimator->estimateFee(nBlocks), + GetMinFee(maxMempoolSize)); } CFeeRate CTxMemPool::estimateSmartFee(int nBlocks, int *answerFoundAtBlocks) const { LOCK(cs); - return minerPolicyEstimator->estimateSmartFee(nBlocks, answerFoundAtBlocks, - *this); + uint64_t maxMempoolSize = + gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; + + // minerPolicy uses recent blocks to figure out a reasonable fee. This may + // disagree + // with the rollingMinimumFeerate under certain scenarios where the blocks + // include low fee + // transactions, but the mempool is being spammed. + // Therefore, use the maximum of the two values. + return std::max(minerPolicyEstimator->estimateSmartFee( + nBlocks, answerFoundAtBlocks, *this), + GetMinFee(maxMempoolSize)); } bool CTxMemPool::WriteFeeEstimates(CAutoFile &fileout) const {