diff options
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -54,6 +54,8 @@ static const unsigned int MAX_ADDR_TO_SEND = 1000; static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000; /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; +/** Maximum number of outgoing nodes */ +static const int MAX_OUTBOUND_CONNECTIONS = 8; /** -listen default */ static const bool DEFAULT_LISTEN = true; /** -upnp default */ @@ -107,7 +109,7 @@ public: CConnman(); ~CConnman(); - bool Start(boost::thread_group& threadGroup, CScheduler& scheduler, ServiceFlags nLocalServicesIn, ServiceFlags nRelevantServicesIn, std::string& strNodeError); + bool Start(boost::thread_group& threadGroup, CScheduler& scheduler, ServiceFlags nLocalServicesIn, ServiceFlags nRelevantServicesIn, int nMaxConnectionsIn, int nMaxOutboundIn, std::string& strNodeError); void Stop(); bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false); bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false, bool fFeeler = false); @@ -284,12 +286,14 @@ private: ServiceFlags nRelevantServices; CSemaphore *semOutbound; + int nMaxConnections; + int nMaxOutbound; }; extern std::unique_ptr<CConnman> g_connman; void MapPort(bool fUseUPnP); unsigned short GetListenPort(); bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false); -bool StartNode(CConnman& connman, boost::thread_group& threadGroup, CScheduler& scheduler, ServiceFlags nLocalServices, ServiceFlags nRelevantServices, std::string& strNodeError); +bool StartNode(CConnman& connman, boost::thread_group& threadGroup, CScheduler& scheduler, ServiceFlags nLocalServices, ServiceFlags nRelevantServices, int nMaxConnections, int nMaxOutbound, std::string& strNodeError); bool StopNode(CConnman& connman); size_t SocketSendData(CNode *pnode); @@ -353,9 +357,6 @@ extern bool fDiscover; extern bool fListen; extern bool fRelayTxes; -/** Maximum number of connections to simultaneously allow (aka connection slots) */ -extern int nMaxConnections; - extern limitedmap<uint256, int64_t> mapAlreadyAskedFor; /** Subversion as sent to the P2P network in `version` messages */ |