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/txmempool.h | |
parent | a7ebe48b94c5a9195c8eabd193204c499cb4bfdb (diff) | |
download | bitcoin-9d3f7eb9860254eb787ebe2734fd6a26bcf365c1.tar.xz |
[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/txmempool.h')
-rw-r--r-- | src/txmempool.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/txmempool.h b/src/txmempool.h index 0f3ae3630c..4568eb928d 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -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 */ |