From cb79b9dbf4cd06e17c8c65b36bf15c3ea2641de4 Mon Sep 17 00:00:00 2001 From: Amiti Uttarwar Date: Mon, 27 Jul 2020 21:30:50 -0700 Subject: [mempool] Revert unbroadcast set to tracking just txid When I originally implemented the unbroadcast set in 18038, it just tracked txids. After 18038 was merged, I offered a patch to 18044 to make the unbroadcast changes compatible with wtxid relay. In this patch, I updated `unbroadcast_txids` to a map of txid -> wtxid. Post merge review comments shed light on the fact that this update was unnecessary, and distracting. So, this commit updates the unbroadcast ids back to a set. --- src/txmempool.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/txmempool.h') diff --git a/src/txmempool.h b/src/txmempool.h index f773cd4825..62a836ce67 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -574,10 +574,9 @@ private: std::vector GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs); /** - * track locally submitted transactions to periodically retry initial broadcast - * map of txid -> wtxid + * Track locally submitted transactions to periodically retry initial broadcast. */ - std::map m_unbroadcast_txids GUARDED_BY(cs); + std::set m_unbroadcast_txids GUARDED_BY(cs); public: indirectmap mapNextTx GUARDED_BY(cs); @@ -739,19 +738,20 @@ public: size_t DynamicMemoryUsage() const; /** Adds a transaction to the unbroadcast set */ - void AddUnbroadcastTx(const uint256& txid, const uint256& wtxid) { + void AddUnbroadcastTx(const uint256& txid) + { LOCK(cs); - // Sanity Check: the transaction should also be in the mempool - if (exists(txid)) { - m_unbroadcast_txids[txid] = wtxid; - } - } + // Sanity check the transaction is in the mempool & insert into + // unbroadcast set. + if (exists(txid)) m_unbroadcast_txids.insert(txid); + }; /** Removes a transaction from the unbroadcast set */ void RemoveUnbroadcastTx(const uint256& txid, const bool unchecked = false); /** Returns transactions in unbroadcast set */ - std::map GetUnbroadcastTxs() const { + std::set GetUnbroadcastTxs() const + { LOCK(cs); return m_unbroadcast_txids; } -- cgit v1.2.3