|
|
@ -789,6 +789,17 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) {
|
|
|
|
|
|
|
|
int expired = pool.Expire(GetTime() - age);
|
|
|
|
|
|
|
|
if (expired != 0)
|
|
|
|
|
|
|
|
LogPrint("mempool", "Expired %i transactions from the memory pool\n", expired);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<uint256> vNoSpendsRemaining;
|
|
|
|
|
|
|
|
pool.TrimToSize(limit, &vNoSpendsRemaining);
|
|
|
|
|
|
|
|
BOOST_FOREACH(const uint256& removed, vNoSpendsRemaining)
|
|
|
|
|
|
|
|
pcoinsTip->Uncache(removed);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CAmount GetMinRelayFee(const CTransaction& tx, const CTxMemPool& pool, unsigned int nBytes, bool fAllowFree)
|
|
|
|
CAmount GetMinRelayFee(const CTransaction& tx, const CTxMemPool& pool, unsigned int nBytes, bool fAllowFree)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint256 hash = tx.GetHash();
|
|
|
|
uint256 hash = tx.GetHash();
|
|
|
@ -1210,12 +1221,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|
|
|
|
|
|
|
|
|
|
|
// trim mempool and check if tx was trimmed
|
|
|
|
// trim mempool and check if tx was trimmed
|
|
|
|
if (!fOverrideMempoolLimit) {
|
|
|
|
if (!fOverrideMempoolLimit) {
|
|
|
|
int expired = pool.Expire(GetTime() - GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60);
|
|
|
|
LimitMempoolSize(pool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60);
|
|
|
|
if (expired != 0)
|
|
|
|
if (!pool.exists(hash))
|
|
|
|
LogPrint("mempool", "Expired %i transactions from the memory pool\n", expired);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
|
|
|
|
|
|
|
|
if (!pool.exists(tx.GetHash()))
|
|
|
|
|
|
|
|
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool full");
|
|
|
|
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool full");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2571,7 +2578,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
|
|
|
|
|
|
|
|
|
|
|
|
if (fBlocksDisconnected) {
|
|
|
|
if (fBlocksDisconnected) {
|
|
|
|
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
|
|
|
|
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
|
|
|
|
mempool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
|
|
|
|
LimitMempoolSize(mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mempool.check(pcoinsTip);
|
|
|
|
mempool.check(pcoinsTip);
|
|
|
|
|
|
|
|
|
|
|
@ -2686,7 +2693,7 @@ bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensus
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mempool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
|
|
|
|
LimitMempoolSize(mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60);
|
|
|
|
|
|
|
|
|
|
|
|
// The resulting new best tip may not be in setBlockIndexCandidates anymore, so
|
|
|
|
// The resulting new best tip may not be in setBlockIndexCandidates anymore, so
|
|
|
|
// add it again.
|
|
|
|
// add it again.
|
|
|
|