From 0df3d3fd6bbbd0e06116797177ba797580553250 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Wed, 23 Dec 2020 17:14:08 +1000 Subject: net_processing: make more of PeerManager private --- src/net_processing.h | 56 ++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) (limited to 'src/net_processing.h') diff --git a/src/net_processing.h b/src/net_processing.h index 076dce1713..28d0c34d78 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -100,41 +100,27 @@ public: CScheduler& scheduler, ChainstateManager& chainman, CTxMemPool& pool, bool ignore_incoming_txs); - /** - * Overridden from CValidationInterface. - */ + /** Overridden from CValidationInterface. */ void BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindexConnected) override; void BlockDisconnected(const std::shared_ptr &block, const CBlockIndex* pindex) override; - /** - * Overridden from CValidationInterface. - */ void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override; - /** - * Overridden from CValidationInterface. - */ void BlockChecked(const CBlock& block, const BlockValidationState& state) override; - /** - * Overridden from CValidationInterface. - */ void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr& pblock) override; + /** Implement NetEventsInterface */ void InitializeNode(CNode* pnode) override; void FinalizeNode(const CNode& node, bool& fUpdateConnectionTime) override; bool ProcessMessages(CNode* pfrom, std::atomic& interrupt) override; bool SendMessages(CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing); - /** Consider evicting an outbound peer based on the amount of time they've been behind our tip */ - void ConsiderEviction(CNode& pto, int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main); - /** Evict extra outbound peers. If we think our tip may be stale, connect to an extra outbound */ - void CheckForStaleTipAndEvictPeers(); - /** If we have extra outbound peers, try to disconnect the one with the oldest block announcement */ - void EvictExtraOutboundPeers(int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main); - /** Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */ - void ReattemptInitialBroadcast(CScheduler& scheduler) const; + /** Get statistics from node state */ + bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats); - /** Process a single message from a peer. Public for fuzz testing */ - void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv, - const std::chrono::microseconds time_received, const std::atomic& interruptMsgProc); + /** Whether this node ignores txs received over p2p. */ + bool IgnoresIncomingTxs() { return m_ignore_incoming_txs; }; + + /** Set the best height */ + void SetBestHeight(int height) { m_best_height = height; }; /** * Increment peer's misbehavior score. If the new value >= DISCOURAGEMENT_THRESHOLD, mark the node @@ -143,16 +129,26 @@ public: */ void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message); - /** Get statistics from node state */ - bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats); - - /** Set the best height */ - void SetBestHeight(int height) { m_best_height = height; }; + /** + * Evict extra outbound peers. If we think our tip may be stale, connect to an extra outbound. + * Public for unit testing. + */ + void CheckForStaleTipAndEvictPeers(); - /** Whether this node ignores txs received over p2p. */ - bool IgnoresIncomingTxs() { return m_ignore_incoming_txs; }; + /** Process a single message from a peer. Public for fuzz testing */ + void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv, + const std::chrono::microseconds time_received, const std::atomic& interruptMsgProc); private: + /** Consider evicting an outbound peer based on the amount of time they've been behind our tip */ + void ConsiderEviction(CNode& pto, int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + + /** If we have extra outbound peers, try to disconnect the one with the oldest block announcement */ + void EvictExtraOutboundPeers(int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + + /** Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */ + void ReattemptInitialBroadcast(CScheduler& scheduler) const; + /** Get a shared pointer to the Peer object. * May return an empty shared_ptr if the Peer object can't be found. */ PeerRef GetPeerRef(NodeId id) const; -- cgit v1.2.3