@@ -100,41 +100,27 @@ class PeerManager final : public CValidationInterface, public NetEventsInterface
100
100
CScheduler& scheduler, ChainstateManager& chainman, CTxMemPool& pool,
101
101
bool ignore_incoming_txs);
102
102
103
- /* *
104
- * Overridden from CValidationInterface.
105
- */
103
+ /* * Overridden from CValidationInterface. */
106
104
void BlockConnected (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override ;
107
105
void BlockDisconnected (const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override ;
108
- /* *
109
- * Overridden from CValidationInterface.
110
- */
111
106
void UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload ) override ;
112
- /* *
113
- * Overridden from CValidationInterface.
114
- */
115
107
void BlockChecked (const CBlock& block, const BlockValidationState& state) override ;
116
- /* *
117
- * Overridden from CValidationInterface.
118
- */
119
108
void NewPoWValidBlock (const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override ;
120
109
110
+ /* * Implement NetEventsInterface */
121
111
void InitializeNode (CNode* pnode) override ;
122
112
void FinalizeNode (const CNode& node, bool & fUpdateConnectionTime ) override ;
123
113
bool ProcessMessages (CNode* pfrom, std::atomic<bool >& interrupt) override ;
124
114
bool SendMessages (CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);
125
115
126
- /* * Consider evicting an outbound peer based on the amount of time they've been behind our tip */
127
- void ConsiderEviction (CNode& pto, int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
128
- /* * Evict extra outbound peers. If we think our tip may be stale, connect to an extra outbound */
129
- void CheckForStaleTipAndEvictPeers ();
130
- /* * If we have extra outbound peers, try to disconnect the one with the oldest block announcement */
131
- void EvictExtraOutboundPeers (int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
132
- /* * Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */
133
- void ReattemptInitialBroadcast (CScheduler& scheduler) const ;
116
+ /* * Get statistics from node state */
117
+ bool GetNodeStateStats (NodeId nodeid, CNodeStateStats& stats);
134
118
135
- /* * Process a single message from a peer. Public for fuzz testing */
136
- void ProcessMessage (CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
137
- const std::chrono::microseconds time_received, const std::atomic<bool >& interruptMsgProc);
119
+ /* * Whether this node ignores txs received over p2p. */
120
+ bool IgnoresIncomingTxs () { return m_ignore_incoming_txs; };
121
+
122
+ /* * Set the best height */
123
+ void SetBestHeight (int height) { m_best_height = height; };
138
124
139
125
/* *
140
126
* Increment peer's misbehavior score. If the new value >= DISCOURAGEMENT_THRESHOLD, mark the node
@@ -143,16 +129,26 @@ class PeerManager final : public CValidationInterface, public NetEventsInterface
143
129
*/
144
130
void Misbehaving (const NodeId pnode, const int howmuch, const std::string& message);
145
131
146
- /* * Get statistics from node state */
147
- bool GetNodeStateStats (NodeId nodeid, CNodeStateStats& stats);
148
-
149
- /* * Set the best height */
150
- void SetBestHeight ( int height) { m_best_height = height; } ;
132
+ /* *
133
+ * Evict extra outbound peers. If we think our tip may be stale, connect to an extra outbound.
134
+ * Public for unit testing.
135
+ */
136
+ void CheckForStaleTipAndEvictPeers () ;
151
137
152
- /* * Whether this node ignores txs received over p2p. */
153
- bool IgnoresIncomingTxs () { return m_ignore_incoming_txs; };
138
+ /* * Process a single message from a peer. Public for fuzz testing */
139
+ void ProcessMessage (CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
140
+ const std::chrono::microseconds time_received, const std::atomic<bool >& interruptMsgProc);
154
141
155
142
private:
143
+ /* * Consider evicting an outbound peer based on the amount of time they've been behind our tip */
144
+ void ConsiderEviction (CNode& pto, int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
145
+
146
+ /* * If we have extra outbound peers, try to disconnect the one with the oldest block announcement */
147
+ void EvictExtraOutboundPeers (int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
148
+
149
+ /* * Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */
150
+ void ReattemptInitialBroadcast (CScheduler& scheduler) const ;
151
+
156
152
/* * Get a shared pointer to the Peer object.
157
153
* May return an empty shared_ptr if the Peer object can't be found. */
158
154
PeerRef GetPeerRef (NodeId id) const ;
0 commit comments