Skip to content

Commit

Permalink
Bump MAX_OUTBOUND_MASTERNODE_CONNECTIONS to 250 on masternodes (bitco…
Browse files Browse the repository at this point in the history
…in#2791)

* Bump MAX_OUTBOUND_MASTERNODE_CONNECTIONS to 250 on masternodes

Masternodes now need to connect to much more other MNs due to the intra-quorum
communication.

250 is a very conservative value loosely based on the absolute worst-case
number of outgoing connections required, assuming that a MN manages to
become part of all 24 active LLMQs.

* Fix infinite loop in CConnman::Interrupt

* Move out conditional calc into it's own variable

Co-Authored-By: codablock <ablock84@gmail.com>
  • Loading branch information
codablock authored and UdjinM6 committed Mar 21, 2019
1 parent 0ed5ae0 commit 071b60d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/net.cpp
Expand Up @@ -2414,7 +2414,7 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c

if (semMasternodeOutbound == NULL) {
// initialize semaphore
semMasternodeOutbound = new CSemaphore(MAX_OUTBOUND_MASTERNODE_CONNECTIONS);
semMasternodeOutbound = new CSemaphore(fMasternodeMode ? MAX_OUTBOUND_MASTERNODE_CONNECTIONS_ON_MN : MAX_OUTBOUND_MASTERNODE_CONNECTIONS);
}

//
Expand Down Expand Up @@ -2519,7 +2519,8 @@ void CConnman::Interrupt()
}

if (semMasternodeOutbound) {
for (int i=0; i<MAX_OUTBOUND_MASTERNODE_CONNECTIONS; i++) {
int nMaxMasternodeOutbound = fMasternodeMode ? MAX_OUTBOUND_MASTERNODE_CONNECTIONS_ON_MN : MAX_OUTBOUND_MASTERNODE_CONNECTIONS;
for (int i = 0; i < nMaxMasternodeOutbound; i++) {
semMasternodeOutbound->post();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/net.h
Expand Up @@ -67,6 +67,7 @@ static const int MAX_OUTBOUND_CONNECTIONS = 8;
static const int MAX_ADDNODE_CONNECTIONS = 8;
/** Maximum number if outgoing masternodes */
static const int MAX_OUTBOUND_MASTERNODE_CONNECTIONS = 30;
static const int MAX_OUTBOUND_MASTERNODE_CONNECTIONS_ON_MN = 250;
/** -listen default */
static const bool DEFAULT_LISTEN = true;
/** -upnp default */
Expand Down

0 comments on commit 071b60d

Please sign in to comment.