mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
[mempool] sanity check that all unbroadcast txns are in mempool
- before reattempting broadcast for unbroadcast txns, check they are in mempool and remove if not - this protects from memory leaks and network spam just in case unbroadcast set (incorrectly) has extra txns - check that tx is in mempool before adding to unbroadcast set to try to prevent this from happening
This commit is contained in:
parent
a7ebe48b94
commit
9d3f7eb986
2 changed files with 10 additions and 2 deletions
|
@ -819,7 +819,12 @@ void PeerLogicValidation::ReattemptInitialBroadcast(CScheduler& scheduler) const
|
|||
std::set<uint256> unbroadcast_txids = m_mempool.GetUnbroadcastTxs();
|
||||
|
||||
for (const uint256& txid : unbroadcast_txids) {
|
||||
RelayTransaction(txid, *connman);
|
||||
// Sanity check: all unbroadcast txns should exist in the mempool
|
||||
if (m_mempool.exists(txid)) {
|
||||
RelayTransaction(txid, *connman);
|
||||
} else {
|
||||
m_mempool.RemoveUnbroadcastTx(txid, true);
|
||||
}
|
||||
}
|
||||
|
||||
// schedule next run for 10-15 minutes in the future
|
||||
|
|
|
@ -704,7 +704,10 @@ public:
|
|||
/** Adds a transaction to the unbroadcast set */
|
||||
void AddUnbroadcastTx(const uint256& txid) {
|
||||
LOCK(cs);
|
||||
m_unbroadcast_txids.insert(txid);
|
||||
/** Sanity Check: the transaction should also be in the mempool */
|
||||
if (exists(txid)) {
|
||||
m_unbroadcast_txids.insert(txid);
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes a transaction from the unbroadcast set */
|
||||
|
|
Loading…
Add table
Reference in a new issue