From 2d4327db1973a354e9e4153de6958d49120fcde8 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 23 Oct 2017 13:36:15 -0400 Subject: net: Allow connecting to extra outbound peers --- src/net.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/net.h') diff --git a/src/net.h b/src/net.h index f373ab0cf1..c90df64992 100644 --- a/src/net.h +++ b/src/net.h @@ -251,6 +251,19 @@ public: void GetBanned(banmap_t &banmap); void SetBanned(const banmap_t &banmap); + // This allows temporarily exceeding nMaxOutbound, with the goal of finding + // a peer that is better than all our current peers. + void SetTryNewOutboundPeer(bool flag); + bool GetTryNewOutboundPeer(); + + // Return the number of outbound peers we have in excess of our target (eg, + // if we previously called SetTryNewOutboundPeer(true), and have since set + // to false, we may have extra peers that we wish to disconnect). This may + // return a value less than (num_outbound_connections - num_outbound_slots) + // in cases where some outbound connections are not yet fully connected, or + // not yet fully disconnected. + int GetExtraOutboundCount(); + bool AddNode(const std::string& node); bool RemoveAddedNode(const std::string& node); std::vector GetAddedNodeInfo(); @@ -413,6 +426,11 @@ private: std::thread threadOpenAddedConnections; std::thread threadOpenConnections; std::thread threadMessageHandler; + + /** flag for deciding to connect to an extra outbound peer, + * in excess of nMaxOutbound + * This takes the place of a feeler connection */ + std::atomic_bool m_try_another_outbound_peer; }; extern std::unique_ptr g_connman; void Discover(boost::thread_group& threadGroup); -- cgit v1.2.3