Skip to content

Commit 44c635d

Browse files
sipafurszy
authored andcommitted
Add AcceptToMemoryPoolWithTime function
1 parent 6bbc6a9 commit 44c635d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/validation.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ std::string FormatStateMessage(const CValidationState &state)
309309
}
310310

311311
bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const CTransactionRef& _tx, bool fLimitFree,
312-
bool* pfMissingInputs, bool fOverrideMempoolLimit, bool fRejectAbsurdFee, bool ignoreFees,
312+
bool* pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit, bool fRejectAbsurdFee, bool ignoreFees,
313313
std::vector<COutPoint>& coins_to_uncache)
314314
{
315315
AssertLockHeld(cs_main);
@@ -495,7 +495,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
495495
}
496496
}
497497

498-
CTxMemPoolEntry entry(_tx, nFees, GetTime(), dPriority, chainHeight, pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbaseOrCoinstake, nSigOps);
498+
CTxMemPoolEntry entry(_tx, nFees, nAcceptTime, dPriority, chainHeight, pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbaseOrCoinstake, nSigOps);
499499
unsigned int nSize = entry.GetTxSize();
500500

501501
// Don't accept it if it can't get into a block
@@ -611,11 +611,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
611611
return true;
612612
}
613613

614-
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransactionRef& tx, bool fLimitFree,
615-
bool* pfMissingInputs, bool fOverrideMempoolLimit, bool fRejectAbsurdFee, bool fIgnoreFees)
614+
bool AcceptToMemoryPoolWithTime(CTxMemPool& pool, CValidationState &state, const CTransactionRef& tx, bool fLimitFree,
615+
bool* pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit, bool fRejectAbsurdFee, bool fIgnoreFees)
616616
{
617617
std::vector<COutPoint> coins_to_uncache;
618-
bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, fOverrideMempoolLimit, fRejectAbsurdFee, fIgnoreFees, coins_to_uncache);
618+
bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime, fOverrideMempoolLimit, fRejectAbsurdFee, fIgnoreFees, coins_to_uncache);
619619
if (!res) {
620620
for (const COutPoint& outpoint: coins_to_uncache)
621621
pcoinsTip->Uncache(outpoint);
@@ -626,6 +626,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
626626
return res;
627627
}
628628

629+
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransactionRef& tx,
630+
bool fLimitFree, bool* pfMissingInputs, bool fOverrideMempoolLimit,
631+
bool fRejectInsaneFee, bool ignoreFees)
632+
{
633+
return AcceptToMemoryPoolWithTime(pool, state, tx, fLimitFree, pfMissingInputs, GetTime(), fOverrideMempoolLimit, fRejectInsaneFee, ignoreFees);
634+
}
635+
629636
bool GetOutput(const uint256& hash, unsigned int index, CValidationState& state, CTxOut& out)
630637
{
631638
CTransaction txPrev;

src/validation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ void FlushStateToDisk();
216216
/** (try to) add transaction to memory pool **/
217217
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransactionRef& tx, bool fLimitFree, bool* pfMissingInputs, bool fOverrideMempoolLimit = false, bool fRejectInsaneFee = false, bool ignoreFees = false);
218218

219+
/** (try to) add transaction to memory pool with a specified acceptance time **/
220+
bool AcceptToMemoryPoolWithTime(CTxMemPool& pool, CValidationState &state, const CTransactionRef &tx, bool fLimitFree,
221+
bool* pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit = false,
222+
bool fRejectInsaneFee = false, bool ignoreFees = false);
223+
219224
/** Convert CValidationState to a human-readable message for logging */
220225
std::string FormatStateMessage(const CValidationState &state);
221226

0 commit comments

Comments
 (0)