Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | CheckInputsFromMempoolAndCache(const CTransaction &tx, CValidationState &state, | ||||
return CheckInputs(tx, state, view, true, flags, cacheSigStore, true, | return CheckInputs(tx, state, view, true, flags, cacheSigStore, true, | ||||
txdata); | txdata); | ||||
} | } | ||||
static bool AcceptToMemoryPoolWorker( | static bool AcceptToMemoryPoolWorker( | ||||
const Config &config, CTxMemPool &pool, CValidationState &state, | const Config &config, CTxMemPool &pool, CValidationState &state, | ||||
const CTransactionRef &ptx, bool fLimitFree, bool *pfMissingInputs, | const CTransactionRef &ptx, bool fLimitFree, bool *pfMissingInputs, | ||||
int64_t nAcceptTime, bool fOverrideMempoolLimit, const Amount nAbsurdFee, | int64_t nAcceptTime, bool fOverrideMempoolLimit, const CFeeRate nAbsurdFee, | ||||
std::vector<COutPoint> &coins_to_uncache) { | std::vector<COutPoint> &coins_to_uncache) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
const CTransaction &tx = *ptx; | const CTransaction &tx = *ptx; | ||||
const TxId txid = tx.GetId(); | const TxId txid = tx.GetId(); | ||||
// mempool "read lock" (held through | // mempool "read lock" (held through | ||||
// GetMainSignals().TransactionAddedToMempool()) | // GetMainSignals().TransactionAddedToMempool()) | ||||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : tx.vin) { | ||||
"rate limited free transaction"); | "rate limited free transaction"); | ||||
} | } | ||||
LogPrint(BCLog::MEMPOOL, "Rate limit dFreeCount: %g => %g\n", | LogPrint(BCLog::MEMPOOL, "Rate limit dFreeCount: %g => %g\n", | ||||
dFreeCount, dFreeCount + nSize); | dFreeCount, dFreeCount + nSize); | ||||
dFreeCount += nSize; | dFreeCount += nSize; | ||||
} | } | ||||
if (nAbsurdFee != Amount::zero() && nFees > nAbsurdFee) { | if (nAbsurdFee != CFeeRate(Amount::zero()) && | ||||
return state.Invalid(false, REJECT_HIGHFEE, "absurdly-high-fee", | nFees > nAbsurdFee.GetFee(nSize)) { | ||||
strprintf("%d > %d", nFees, nAbsurdFee)); | return state.Invalid( | ||||
false, REJECT_HIGHFEE, "absurdly-high-fee", | |||||
strprintf("%d > %d", nFees, nAbsurdFee.GetFee(nSize))); | |||||
} | } | ||||
// Calculate in-mempool ancestors, up to a limit. | // Calculate in-mempool ancestors, up to a limit. | ||||
CTxMemPool::setEntries setAncestors; | CTxMemPool::setEntries setAncestors; | ||||
size_t nLimitAncestors = | size_t nLimitAncestors = | ||||
gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); | gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); | ||||
size_t nLimitAncestorSize = | size_t nLimitAncestorSize = | ||||
gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * | gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* (try to) add transaction to memory pool with a specified acceptance time. | * (try to) add transaction to memory pool with a specified acceptance time. | ||||
*/ | */ | ||||
static bool AcceptToMemoryPoolWithTime( | static bool AcceptToMemoryPoolWithTime( | ||||
const Config &config, CTxMemPool &pool, CValidationState &state, | const Config &config, CTxMemPool &pool, CValidationState &state, | ||||
const CTransactionRef &tx, bool fLimitFree, bool *pfMissingInputs, | const CTransactionRef &tx, bool fLimitFree, bool *pfMissingInputs, | ||||
int64_t nAcceptTime, bool fOverrideMempoolLimit = false, | int64_t nAcceptTime, bool fOverrideMempoolLimit = false, | ||||
const Amount nAbsurdFee = Amount::zero()) { | const CFeeRate nAbsurdFee = CFeeRate(Amount::zero())) { | ||||
std::vector<COutPoint> coins_to_uncache; | std::vector<COutPoint> coins_to_uncache; | ||||
bool res = AcceptToMemoryPoolWorker( | bool res = AcceptToMemoryPoolWorker( | ||||
config, pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime, | config, pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime, | ||||
fOverrideMempoolLimit, nAbsurdFee, coins_to_uncache); | fOverrideMempoolLimit, nAbsurdFee, coins_to_uncache); | ||||
if (!res) { | if (!res) { | ||||
for (const COutPoint &outpoint : coins_to_uncache) { | for (const COutPoint &outpoint : coins_to_uncache) { | ||||
pcoinsTip->Uncache(outpoint); | pcoinsTip->Uncache(outpoint); | ||||
} | } | ||||
} | } | ||||
// After we've (potentially) uncached entries, ensure our coins cache is | // After we've (potentially) uncached entries, ensure our coins cache is | ||||
// still within its size limits | // still within its size limits | ||||
CValidationState stateDummy; | CValidationState stateDummy; | ||||
FlushStateToDisk(config.GetChainParams(), stateDummy, FLUSH_STATE_PERIODIC); | FlushStateToDisk(config.GetChainParams(), stateDummy, FLUSH_STATE_PERIODIC); | ||||
return res; | return res; | ||||
} | } | ||||
bool AcceptToMemoryPool(const Config &config, CTxMemPool &pool, | bool AcceptToMemoryPool(const Config &config, CTxMemPool &pool, | ||||
CValidationState &state, const CTransactionRef &tx, | CValidationState &state, const CTransactionRef &tx, | ||||
bool fLimitFree, bool *pfMissingInputs, | bool fLimitFree, bool *pfMissingInputs, | ||||
bool fOverrideMempoolLimit, const Amount nAbsurdFee) { | bool fOverrideMempoolLimit, const CFeeRate nAbsurdFee) { | ||||
return AcceptToMemoryPoolWithTime(config, pool, state, tx, fLimitFree, | return AcceptToMemoryPoolWithTime(config, pool, state, tx, fLimitFree, | ||||
pfMissingInputs, GetTime(), | pfMissingInputs, GetTime(), | ||||
fOverrideMempoolLimit, nAbsurdFee); | fOverrideMempoolLimit, nAbsurdFee); | ||||
} | } | ||||
/** | /** | ||||
* Return transaction in txOut, and if it was found inside a block, its hash is | * Return transaction in txOut, and if it was found inside a block, its hash is | ||||
* placed in hashBlock. | * placed in hashBlock. | ||||
▲ Show 20 Lines • Show All 4,484 Lines • Show Last 20 Lines |