@@ -800,32 +800,6 @@ void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) {
800800 pcoinsTip->Uncache (removed);
801801}
802802
803- CAmount GetMinRelayFee (const CTransaction& tx, const CTxMemPool& pool, unsigned int nBytes, bool fAllowFree )
804- {
805- uint256 hash = tx.GetHash ();
806- double dPriorityDelta = 0 ;
807- CAmount nFeeDelta = 0 ;
808- pool.ApplyDeltas (hash, dPriorityDelta, nFeeDelta);
809- if (dPriorityDelta > 0 || nFeeDelta > 0 )
810- return 0 ;
811-
812- CAmount nMinFee = ::minRelayTxFee.GetFee (nBytes);
813-
814- if (fAllowFree )
815- {
816- // There is a free transaction area in blocks created by most miners,
817- // * If we are relaying we allow transactions up to DEFAULT_BLOCK_PRIORITY_SIZE - 1000
818- // to be considered to fall into this category. We don't want to encourage sending
819- // multiple transactions instead of one big transaction to avoid fees.
820- if (nBytes < (DEFAULT_BLOCK_PRIORITY_SIZE - 1000 ))
821- nMinFee = 0 ;
822- }
823-
824- if (!MoneyRange (nMinFee))
825- nMinFee = MAX_MONEY;
826- return nMinFee;
827- }
828-
829803/* * Convert CValidationState to a human-readable message for logging */
830804std::string FormatStateMessage (const CValidationState &state)
831805{
@@ -968,6 +942,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
968942
969943 CAmount nValueOut = tx.GetValueOut ();
970944 CAmount nFees = nValueIn-nValueOut;
945+ // nModifiedFees includes any fee deltas from PrioritiseTransaction
946+ CAmount nModifiedFees = nFees;
947+ double nPriorityDummy = 0 ;
948+ pool.ApplyDeltas (hash, nPriorityDummy, nModifiedFees);
949+
971950 CAmount inChainInputValue;
972951 double dPriority = view.GetPriority (tx, chainActive.Height (), inChainInputValue);
973952
@@ -985,24 +964,18 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
985964 CTxMemPoolEntry entry (tx, nFees, GetTime (), dPriority, chainActive.Height (), pool.HasNoInputsOf (tx), inChainInputValue, fSpendsCoinbase , nSigOps);
986965 unsigned int nSize = entry.GetTxSize ();
987966
988- // Don't accept it if it can't get into a block
989- CAmount txMinFee = GetMinRelayFee (tx, pool, nSize, true );
990- if (fLimitFree && nFees < txMinFee)
991- return state.DoS (0 , false , REJECT_INSUFFICIENTFEE, " insufficient fee" , false ,
992- strprintf (" %d < %d" , nFees, txMinFee));
993-
994967 CAmount mempoolRejectFee = pool.GetMinFee (GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 ).GetFee (nSize);
995- if (mempoolRejectFee > 0 && nFees < mempoolRejectFee) {
968+ if (mempoolRejectFee > 0 && nModifiedFees < mempoolRejectFee) {
996969 return state.DoS (0 , false , REJECT_INSUFFICIENTFEE, " mempool min fee not met" , false , strprintf (" %d < %d" , nFees, mempoolRejectFee));
997- } else if (GetBoolArg (" -relaypriority" , DEFAULT_RELAYPRIORITY) && nFees < ::minRelayTxFee.GetFee (nSize) && !AllowFree (entry.GetPriority (chainActive.Height () + 1 ))) {
970+ } else if (GetBoolArg (" -relaypriority" , DEFAULT_RELAYPRIORITY) && nModifiedFees < ::minRelayTxFee.GetFee (nSize) && !AllowFree (entry.GetPriority (chainActive.Height () + 1 ))) {
998971 // Require that free transactions have sufficient priority to be mined in the next block.
999972 return state.DoS (0 , false , REJECT_INSUFFICIENTFEE, " insufficient priority" );
1000973 }
1001974
1002975 // Continuously rate-limit free (really, very-low-fee) transactions
1003976 // This mitigates 'penny-flooding' -- sending thousands of free transactions just to
1004977 // be annoying or make others' transactions take longer to confirm.
1005- if (fLimitFree && nFees < ::minRelayTxFee.GetFee (nSize))
978+ if (fLimitFree && nModifiedFees < ::minRelayTxFee.GetFee (nSize))
1006979 {
1007980 static CCriticalSection csFreeLimiter;
1008981 static double dFreeCount;
@@ -1067,7 +1040,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
10671040 LOCK (pool.cs );
10681041 if (setConflicts.size ())
10691042 {
1070- CFeeRate newFeeRate (nFees , nSize);
1043+ CFeeRate newFeeRate (nModifiedFees , nSize);
10711044 set<uint256> setConflictsParents;
10721045 const int maxDescendantsToVisit = 100 ;
10731046 CTxMemPool::setEntries setIterConflicting;
@@ -1110,7 +1083,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
11101083 // ignored when deciding whether or not to replace, we do
11111084 // require the replacement to pay more overall fees too,
11121085 // mitigating most cases.
1113- CFeeRate oldFeeRate (mi->GetFee (), mi->GetTxSize ());
1086+ CFeeRate oldFeeRate (mi->GetModifiedFee (), mi->GetTxSize ());
11141087 if (newFeeRate <= oldFeeRate)
11151088 {
11161089 return state.DoS (0 ,
@@ -1138,7 +1111,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
11381111 pool.CalculateDescendants (it, allConflicting);
11391112 }
11401113 BOOST_FOREACH (CTxMemPool::txiter it, allConflicting) {
1141- nConflictingFees += it->GetFee ();
1114+ nConflictingFees += it->GetModifiedFee ();
11421115 nConflictingSize += it->GetTxSize ();
11431116 }
11441117 } else {
@@ -1171,16 +1144,16 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
11711144 // The replacement must pay greater fees than the transactions it
11721145 // replaces - if we did the bandwidth used by those conflicting
11731146 // transactions would not be paid for.
1174- if (nFees < nConflictingFees)
1147+ if (nModifiedFees < nConflictingFees)
11751148 {
11761149 return state.DoS (0 , error (" AcceptToMemoryPool: rejecting replacement %s, less fees than conflicting txs; %s < %s" ,
1177- hash.ToString (), FormatMoney (nFees ), FormatMoney (nConflictingFees)),
1150+ hash.ToString (), FormatMoney (nModifiedFees ), FormatMoney (nConflictingFees)),
11781151 REJECT_INSUFFICIENTFEE, " insufficient fee" );
11791152 }
11801153
11811154 // Finally in addition to paying more fees than the conflicts the
11821155 // new transaction must pay for its own bandwidth.
1183- CAmount nDeltaFees = nFees - nConflictingFees;
1156+ CAmount nDeltaFees = nModifiedFees - nConflictingFees;
11841157 if (nDeltaFees < ::minRelayTxFee.GetFee (nSize))
11851158 {
11861159 return state.DoS (0 ,
@@ -1218,7 +1191,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
12181191 LogPrint (" mempool" , " replacing tx %s with %s for %s BTC additional fees, %d delta bytes\n " ,
12191192 it->GetTx ().GetHash ().ToString (),
12201193 hash.ToString (),
1221- FormatMoney (nFees - nConflictingFees),
1194+ FormatMoney (nModifiedFees - nConflictingFees),
12221195 (int )nSize - (int )nConflictingSize);
12231196 }
12241197 pool.RemoveStaged (allConflicting);
0 commit comments