diff options
author | gzhao408 <gzhao408@berkeley.edu> | 2020-05-01 15:48:23 -0700 |
---|---|---|
committer | gzhao408 <gzhao408@berkeley.edu> | 2020-05-19 14:23:19 -0700 |
commit | 9d3f7eb9860254eb787ebe2734fd6a26bcf365c1 (patch) | |
tree | c1acea6568f9dd071859a4af0570984920157f81 /src/net_processing.cpp | |
parent | a7ebe48b94c5a9195c8eabd193204c499cb4bfdb (diff) |
[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
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r-- | src/net_processing.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 7e9bb2f27c..817ec1d79b 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -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 |