Skip to content

Commit ced7c94

Browse files
committed
Add AcceptToMemoryPoolWithTime function
1 parent c3efb58 commit ced7c94

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/main.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ std::string FormatStateMessage(const CValidationState &state)
11351135
}
11361136

11371137
bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const CTransaction& tx, bool fLimitFree,
1138-
bool* pfMissingInputs, bool fOverrideMempoolLimit, const CAmount& nAbsurdFee,
1138+
bool* pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit, const CAmount& nAbsurdFee,
11391139
std::vector<uint256>& vHashTxnToUncache)
11401140
{
11411141
const uint256 hash = tx.GetHash();
@@ -1308,7 +1308,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
13081308
}
13091309
}
13101310

1311-
CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbase, nSigOpsCost, lp);
1311+
CTxMemPoolEntry entry(tx, nFees, nAcceptTime, dPriority, chainActive.Height(), pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbase, nSigOpsCost, lp);
13121312
unsigned int nSize = entry.GetTxSize();
13131313

13141314
// Check that the transaction doesn't have an excessive number of
@@ -1572,18 +1572,24 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
15721572
return true;
15731573
}
15741574

1575-
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
1576-
bool* pfMissingInputs, bool fOverrideMempoolLimit, const CAmount nAbsurdFee)
1575+
bool AcceptToMemoryPoolWithTime(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
1576+
bool* pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit, const CAmount nAbsurdFee)
15771577
{
15781578
std::vector<uint256> vHashTxToUncache;
1579-
bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, fOverrideMempoolLimit, nAbsurdFee, vHashTxToUncache);
1579+
bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime, fOverrideMempoolLimit, nAbsurdFee, vHashTxToUncache);
15801580
if (!res) {
15811581
BOOST_FOREACH(const uint256& hashTx, vHashTxToUncache)
15821582
pcoinsTip->Uncache(hashTx);
15831583
}
15841584
return res;
15851585
}
15861586

1587+
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
1588+
bool* pfMissingInputs, bool fOverrideMempoolLimit, const CAmount nAbsurdFee)
1589+
{
1590+
return AcceptToMemoryPoolWithTime(pool, state, tx, fLimitFree, pfMissingInputs, GetTime(), fOverrideMempoolLimit, nAbsurdFee);
1591+
}
1592+
15871593
/** Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock */
15881594
bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::Params& consensusParams, uint256 &hashBlock, bool fAllowSlow)
15891595
{

src/main.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ void PruneAndFlush();
291291
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
292292
bool* pfMissingInputs, bool fOverrideMempoolLimit=false, const CAmount nAbsurdFee=0);
293293

294+
/** (try to) add transaction to memory pool with a specified acceptance time **/
295+
bool AcceptToMemoryPoolWithTime(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
296+
bool* pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit=false, const CAmount nAbsurdFee=0);
297+
294298
/** Convert CValidationState to a human-readable message for logging */
295299
std::string FormatStateMessage(const CValidationState &state);
296300

0 commit comments

Comments
 (0)