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