Skip to content

Commit 0df3d3f

Browse files
committed
net_processing: make more of PeerManager private
1 parent 0d246a5 commit 0df3d3f

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

src/net_processing.h

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,41 +100,27 @@ class PeerManager final : public CValidationInterface, public NetEventsInterface
100100
CScheduler& scheduler, ChainstateManager& chainman, CTxMemPool& pool,
101101
bool ignore_incoming_txs);
102102

103-
/**
104-
* Overridden from CValidationInterface.
105-
*/
103+
/** Overridden from CValidationInterface. */
106104
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
107105
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override;
108-
/**
109-
* Overridden from CValidationInterface.
110-
*/
111106
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
112-
/**
113-
* Overridden from CValidationInterface.
114-
*/
115107
void BlockChecked(const CBlock& block, const BlockValidationState& state) override;
116-
/**
117-
* Overridden from CValidationInterface.
118-
*/
119108
void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override;
120109

110+
/** Implement NetEventsInterface */
121111
void InitializeNode(CNode* pnode) override;
122112
void FinalizeNode(const CNode& node, bool& fUpdateConnectionTime) override;
123113
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
124114
bool SendMessages(CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);
125115

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);
134118

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; };
138124

139125
/**
140126
* 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
143129
*/
144130
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message);
145131

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();
151137

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);
154141

155142
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+
156152
/** Get a shared pointer to the Peer object.
157153
* May return an empty shared_ptr if the Peer object can't be found. */
158154
PeerRef GetPeerRef(NodeId id) const;

0 commit comments

Comments
 (0)