Skip to content

Commit 30ac1d3

Browse files
committed
squash-or-nack: can CTxMemPool::GetMinFee use the global directly?
1 parent e2a9957 commit 30ac1d3

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
973973
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient fee", false,
974974
strprintf("%d < %d", nFees, txMinFee));
975975

976-
CAmount mempoolRejectFee = pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(nSize);
976+
CAmount mempoolRejectFee = pool.GetMinFee().GetFee(nSize);
977977
if (mempoolRejectFee > 0 && nFees < mempoolRejectFee) {
978978
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));
979979
} else if (GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(entry.GetPriority(chainActive.Height() + 1))) {

src/rpcblockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ UniValue mempoolInfoToJSON()
782782
ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage()));
783783
size_t maxmempool = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
784784
ret.push_back(Pair("maxmempool", (int64_t) maxmempool));
785-
ret.push_back(Pair("mempoolminfee", ValueFromAmount(mempool.GetMinFee(maxmempool).GetFeePerK())));
785+
ret.push_back(Pair("mempoolminfee", ValueFromAmount(mempool.GetMinFee().GetFeePerK())));
786786

787787
return ret;
788788
}

src/txmempool.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ CFeeRate CTxMemPool::estimateFee(int nBlocks) const
714714
CFeeRate CTxMemPool::estimateSmartFee(int nBlocks, int *answerFoundAtBlocks) const
715715
{
716716
LOCK(cs);
717-
return minerPolicyEstimator->estimateSmartFee(nBlocks, answerFoundAtBlocks, GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK());
717+
return minerPolicyEstimator->estimateSmartFee(nBlocks, answerFoundAtBlocks, GetMinFee().GetFeePerK());
718718
}
719719
double CTxMemPool::estimatePriority(int nBlocks) const
720720
{
@@ -724,7 +724,7 @@ double CTxMemPool::estimatePriority(int nBlocks) const
724724
double CTxMemPool::estimateSmartPriority(int nBlocks, int *answerFoundAtBlocks) const
725725
{
726726
LOCK(cs);
727-
return minerPolicyEstimator->estimateSmartPriority(nBlocks, answerFoundAtBlocks, GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK());
727+
return minerPolicyEstimator->estimateSmartPriority(nBlocks, answerFoundAtBlocks, GetMinFee().GetFeePerK());
728728
}
729729

730730
bool
@@ -916,6 +916,11 @@ CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
916916
return std::max(CFeeRate(rollingMinimumFeeRate), minReasonableRelayFee);
917917
}
918918

919+
CFeeRate CTxMemPool::GetMinFee() const
920+
{
921+
return GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
922+
}
923+
919924
void CTxMemPool::trackPackageRemoved(const CFeeRate& rate) {
920925
AssertLockHeld(cs);
921926
if (rate.GetFeePerK() > rollingMinimumFeeRate) {

src/txmempool.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ class CTxMemPool
443443
* takes the fee rate to go back down all the way to 0. When the feerate
444444
* would otherwise be half of this, it is set to 0 instead.
445445
*/
446+
CFeeRate GetMinFee() const;
447+
/** Additional version with sizelimit as parameter, useful for testing. */
446448
CFeeRate GetMinFee(size_t sizelimit) const;
447449

448450
/** Remove transactions from the mempool until its dynamic size is <= sizelimit. */

0 commit comments

Comments
 (0)