@@ -440,30 +440,37 @@ class PeerManagerImpl final : public PeerManager
440
440
CTxMemPool& pool, bool ignore_incoming_txs);
441
441
442
442
/* * Overridden from CValidationInterface. */
443
- void BlockConnected (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override ;
444
- void BlockDisconnected (const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override ;
445
- void UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload ) override ;
446
- void BlockChecked (const CBlock& block, const BlockValidationState& state) override ;
443
+ void BlockConnected (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override
444
+ EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex);
445
+ void BlockDisconnected (const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override
446
+ EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex);
447
+ void UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload ) override
448
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
449
+ void BlockChecked (const CBlock& block, const BlockValidationState& state) override
450
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
447
451
void NewPoWValidBlock (const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override ;
448
452
449
453
/* * Implement NetEventsInterface */
450
- void InitializeNode (CNode* pnode) override ;
451
- void FinalizeNode (const CNode& node) override ;
452
- bool ProcessMessages (CNode* pfrom, std::atomic<bool >& interrupt) override ;
453
- bool SendMessages (CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);
454
+ void InitializeNode (CNode* pnode) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
455
+ void FinalizeNode (const CNode& node) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
456
+ bool ProcessMessages (CNode* pfrom, std::atomic<bool >& interrupt) override
457
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex);
458
+ bool SendMessages (CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing)
459
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex);
454
460
455
461
/* * Implement PeerManager */
456
462
void StartScheduledTasks (CScheduler& scheduler) override ;
457
463
void CheckForStaleTipAndEvictPeers () override ;
458
464
std::optional<std::string> FetchBlock (NodeId peer_id, const CBlockIndex& block_index) override ;
459
- bool GetNodeStateStats (NodeId nodeid, CNodeStateStats& stats) const override ;
465
+ bool GetNodeStateStats (NodeId nodeid, CNodeStateStats& stats) const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) ;
460
466
bool IgnoresIncomingTxs () override { return m_ignore_incoming_txs; }
461
- void SendPings () override ;
462
- void RelayTransaction (const uint256& txid, const uint256& wtxid) override ;
467
+ void SendPings () override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) ;
468
+ void RelayTransaction (const uint256& txid, const uint256& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) ;
463
469
void SetBestHeight (int height) override { m_best_height = height; };
464
- void Misbehaving (const NodeId pnode, const int howmuch, const std::string& message) override ;
470
+ void Misbehaving (const NodeId pnode, const int howmuch, const std::string& message) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) ;
465
471
void ProcessMessage (CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
466
- const std::chrono::microseconds time_received, const std::atomic<bool >& interruptMsgProc) override ;
472
+ const std::chrono::microseconds time_received, const std::atomic<bool >& interruptMsgProc) override
473
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex);
467
474
void UpdateLastBlockAnnounceTime (NodeId node, int64_t time_in_seconds) override ;
468
475
469
476
private:
@@ -474,15 +481,15 @@ class PeerManagerImpl final : public PeerManager
474
481
void EvictExtraOutboundPeers (std::chrono::seconds now) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
475
482
476
483
/* * Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */
477
- void ReattemptInitialBroadcast (CScheduler& scheduler);
484
+ void ReattemptInitialBroadcast (CScheduler& scheduler) EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) ;
478
485
479
486
/* * Get a shared pointer to the Peer object.
480
487
* May return an empty shared_ptr if the Peer object can't be found. */
481
- PeerRef GetPeerRef (NodeId id) const ;
488
+ PeerRef GetPeerRef (NodeId id) const EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) ;
482
489
483
490
/* * Get a shared pointer to the Peer object and remove it from m_peer_map.
484
491
* May return an empty shared_ptr if the Peer object can't be found. */
485
- PeerRef RemovePeer (NodeId id);
492
+ PeerRef RemovePeer (NodeId id) EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) ;
486
493
487
494
/* *
488
495
* Potentially mark a node discouraged based on the contents of a BlockValidationState object
@@ -495,14 +502,16 @@ class PeerManagerImpl final : public PeerManager
495
502
* @return Returns true if the peer was punished (probably disconnected)
496
503
*/
497
504
bool MaybePunishNodeForBlock (NodeId nodeid, const BlockValidationState& state,
498
- bool via_compact_block, const std::string& message = " " );
505
+ bool via_compact_block, const std::string& message = " " )
506
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
499
507
500
508
/* *
501
509
* Potentially disconnect and discourage a node based on the contents of a TxValidationState object
502
510
*
503
511
* @return Returns true if the peer was punished (probably disconnected)
504
512
*/
505
- bool MaybePunishNodeForTx (NodeId nodeid, const TxValidationState& state, const std::string& message = " " );
513
+ bool MaybePunishNodeForTx (NodeId nodeid, const TxValidationState& state, const std::string& message = " " )
514
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
506
515
507
516
/* * Maybe disconnect a peer and discourage future connections from its address.
508
517
*
@@ -512,13 +521,16 @@ class PeerManagerImpl final : public PeerManager
512
521
*/
513
522
bool MaybeDiscourageAndDisconnect (CNode& pnode, Peer& peer);
514
523
515
- void ProcessOrphanTx (std::set<uint256>& orphan_work_set) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans);
524
+ void ProcessOrphanTx (std::set<uint256>& orphan_work_set) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans)
525
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
516
526
/* * Process a single headers message from a peer. */
517
527
void ProcessHeadersMessage (CNode& pfrom, const Peer& peer,
518
528
const std::vector<CBlockHeader>& headers,
519
- bool via_compact_block);
529
+ bool via_compact_block)
530
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
520
531
521
- void SendBlockTransactions (CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req);
532
+ void SendBlockTransactions (CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req)
533
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
522
534
523
535
/* * Register with TxRequestTracker that an INV has been received from a
524
536
* peer. The announcement parameters are decided in PeerManager and then
@@ -545,7 +557,7 @@ class PeerManagerImpl final : public PeerManager
545
557
* @param[in] fReachable Whether the address' network is reachable. We relay unreachable
546
558
* addresses less.
547
559
*/
548
- void RelayAddress (NodeId originator, const CAddress& addr, bool fReachable );
560
+ void RelayAddress (NodeId originator, const CAddress& addr, bool fReachable ) EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) ;
549
561
550
562
/* * Send `feefilter` message. */
551
563
void MaybeSendFeefilter (CNode& node, Peer& peer, std::chrono::microseconds current_time);
@@ -615,7 +627,8 @@ class PeerManagerImpl final : public PeerManager
615
627
/* * Number of preferable block download peers. */
616
628
int m_num_preferred_download_peers GUARDED_BY (cs_main){0 };
617
629
618
- bool AlreadyHaveTx (const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
630
+ bool AlreadyHaveTx (const GenTxid& gtxid)
631
+ EXCLUSIVE_LOCKS_REQUIRED(cs_main, !m_recent_confirmed_transactions_mutex);
619
632
620
633
/* *
621
634
* Filter for transactions that were recently rejected by the mempool.
0 commit comments