|
|
@ -776,7 +776,7 @@ static std::string FormatStateMessage(const CValidationState &state) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, |
|
|
|
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, |
|
|
|
bool* pfMissingInputs, bool fRejectAbsurdFee) |
|
|
|
bool* pfMissingInputs, bool fOverrideMempoolLimit, bool fRejectAbsurdFee) |
|
|
|
{ |
|
|
|
{ |
|
|
|
AssertLockHeld(cs_main); |
|
|
|
AssertLockHeld(cs_main); |
|
|
|
if (pfMissingInputs) |
|
|
|
if (pfMissingInputs) |
|
|
@ -956,13 +956,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa |
|
|
|
pool.addUnchecked(hash, entry, setAncestors, !IsInitialBlockDownload()); |
|
|
|
pool.addUnchecked(hash, entry, setAncestors, !IsInitialBlockDownload()); |
|
|
|
|
|
|
|
|
|
|
|
// trim mempool and check if tx was trimmed
|
|
|
|
// trim mempool and check if tx was trimmed
|
|
|
|
int expired = pool.Expire(GetTime() - GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); |
|
|
|
if (!fOverrideMempoolLimit) { |
|
|
|
if (expired != 0) |
|
|
|
int expired = pool.Expire(GetTime() - GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); |
|
|
|
LogPrint("mempool", "Expired %i transactions from the memory pool\n", expired); |
|
|
|
if (expired != 0) |
|
|
|
|
|
|
|
LogPrint("mempool", "Expired %i transactions from the memory pool\n", expired); |
|
|
|
|
|
|
|
|
|
|
|
pool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000); |
|
|
|
pool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000); |
|
|
|
if (!pool.exists(tx.GetHash())) |
|
|
|
if (!pool.exists(tx.GetHash())) |
|
|
|
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool full"); |
|
|
|
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool full"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SyncWithWallets(tx, NULL); |
|
|
|
SyncWithWallets(tx, NULL); |
|
|
@ -2029,7 +2031,7 @@ void static UpdateTip(CBlockIndex *pindexNew) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Disconnect chainActive's tip. */ |
|
|
|
/** Disconnect chainActive's tip. You want to manually re-limit mempool size after this */ |
|
|
|
bool static DisconnectTip(CValidationState &state) { |
|
|
|
bool static DisconnectTip(CValidationState &state) { |
|
|
|
CBlockIndex *pindexDelete = chainActive.Tip(); |
|
|
|
CBlockIndex *pindexDelete = chainActive.Tip(); |
|
|
|
assert(pindexDelete); |
|
|
|
assert(pindexDelete); |
|
|
@ -2056,7 +2058,7 @@ bool static DisconnectTip(CValidationState &state) { |
|
|
|
// ignore validation errors in resurrected transactions
|
|
|
|
// ignore validation errors in resurrected transactions
|
|
|
|
list<CTransaction> removed; |
|
|
|
list<CTransaction> removed; |
|
|
|
CValidationState stateDummy; |
|
|
|
CValidationState stateDummy; |
|
|
|
if (tx.IsCoinBase() || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL)) { |
|
|
|
if (tx.IsCoinBase() || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL, true)) { |
|
|
|
mempool.remove(tx, removed, true); |
|
|
|
mempool.remove(tx, removed, true); |
|
|
|
} else if (mempool.exists(tx.GetHash())) { |
|
|
|
} else if (mempool.exists(tx.GetHash())) { |
|
|
|
vHashUpdate.push_back(tx.GetHash()); |
|
|
|
vHashUpdate.push_back(tx.GetHash()); |
|
|
@ -2229,9 +2231,11 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo |
|
|
|
const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork); |
|
|
|
const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork); |
|
|
|
|
|
|
|
|
|
|
|
// Disconnect active blocks which are no longer in the best chain.
|
|
|
|
// Disconnect active blocks which are no longer in the best chain.
|
|
|
|
|
|
|
|
bool fBlocksDisconnected = false; |
|
|
|
while (chainActive.Tip() && chainActive.Tip() != pindexFork) { |
|
|
|
while (chainActive.Tip() && chainActive.Tip() != pindexFork) { |
|
|
|
if (!DisconnectTip(state)) |
|
|
|
if (!DisconnectTip(state)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
fBlocksDisconnected = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Build list of new blocks to connect.
|
|
|
|
// Build list of new blocks to connect.
|
|
|
@ -2277,6 +2281,9 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fBlocksDisconnected) |
|
|
|
|
|
|
|
mempool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000); |
|
|
|
|
|
|
|
|
|
|
|
// Callbacks/notifications for a new best chain.
|
|
|
|
// Callbacks/notifications for a new best chain.
|
|
|
|
if (fInvalidFound) |
|
|
|
if (fInvalidFound) |
|
|
|
CheckForkWarningConditionsOnNewFork(vpindexToConnect.back()); |
|
|
|
CheckForkWarningConditionsOnNewFork(vpindexToConnect.back()); |
|
|
@ -2363,6 +2370,8 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mempool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000); |
|
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
BlockMap::iterator it = mapBlockIndex.begin(); |
|
|
|
BlockMap::iterator it = mapBlockIndex.begin(); |
|
|
|