Skip to content

Commit 89e2e0d

Browse files
committed
net_processing: move extra transactions to msgproc mutex
Previously vExtraTxnForCompact and vExtraTxnForCompactIt were protected by g_cs_orphans; protect them by g_msgproc_mutex instead, as they are only used during message processing.
1 parent ff8d44d commit 89e2e0d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/net_processing.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ class PeerManagerImpl final : public PeerManager
590590
bool MaybeDiscourageAndDisconnect(CNode& pnode, Peer& peer);
591591

592592
void ProcessOrphanTx(std::set<uint256>& orphan_work_set) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans)
593-
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
593+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex);
594594
/** Process a single headers message from a peer.
595595
*
596596
* @param[in] pfrom CNode of the peer
@@ -924,14 +924,14 @@ class PeerManagerImpl final : public PeerManager
924924
/** Storage for orphan information */
925925
TxOrphanage m_orphanage;
926926

927-
void AddToCompactExtraTransactions(const CTransactionRef& tx) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
927+
void AddToCompactExtraTransactions(const CTransactionRef& tx) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
928928

929929
/** Orphan/conflicted/etc transactions that are kept for compact block reconstruction.
930930
* The last -blockreconstructionextratxn/DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN of
931931
* these are kept in a ring buffer */
932-
std::vector<std::pair<uint256, CTransactionRef>> vExtraTxnForCompact GUARDED_BY(g_cs_orphans);
932+
std::vector<std::pair<uint256, CTransactionRef>> vExtraTxnForCompact GUARDED_BY(g_msgproc_mutex);
933933
/** Offset into vExtraTxnForCompact to insert the next tx */
934-
size_t vExtraTxnForCompactIt GUARDED_BY(g_cs_orphans) = 0;
934+
size_t vExtraTxnForCompactIt GUARDED_BY(g_msgproc_mutex) = 0;
935935

936936
/** Check whether the last unknown block a peer advertised is not yet known. */
937937
void ProcessBlockAvailability(NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
@@ -2885,6 +2885,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
28852885
*/
28862886
void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
28872887
{
2888+
AssertLockHeld(g_msgproc_mutex);
28882889
AssertLockHeld(cs_main);
28892890
AssertLockHeld(g_cs_orphans);
28902891

src/txorphanage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <primitives/transaction.h>
1111
#include <sync.h>
1212

13-
/** Guards orphan transactions and extra txs for compact blocks */
13+
/** Guards orphan transactions */
1414
extern RecursiveMutex g_cs_orphans;
1515

1616
/** A class to track orphan transactions (failed on TX_MISSING_INPUTS)

0 commit comments

Comments
 (0)