Browse Source

Remove redundant whiteconnections option

0.13
Patrick Strateman 9 years ago
parent
commit
a8f6e45249
  1. 29
      src/init.cpp
  2. 1
      src/net.cpp
  3. 11
      src/net.h

29
src/init.cpp

@ -335,7 +335,6 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-whitebind=<addr>", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6")); strUsage += HelpMessageOpt("-whitebind=<addr>", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6"));
strUsage += HelpMessageOpt("-whitelist=<netmask>", _("Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times.") + strUsage += HelpMessageOpt("-whitelist=<netmask>", _("Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times.") +
" " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway")); " " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway"));
strUsage += HelpMessageOpt("-whiteconnections=<n>", strprintf(_("Reserve this many inbound connections for whitelisted peers (default: %d)"), 0));
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
strUsage += HelpMessageGroup(_("Wallet options:")); strUsage += HelpMessageGroup(_("Wallet options:"));
@ -754,25 +753,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-whitebind"), 1); int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-whitebind"), 1);
int nUserMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); int nUserMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
nMaxConnections = std::max(nUserMaxConnections, 0); nMaxConnections = std::max(nUserMaxConnections, 0);
int nUserWhiteConnections = GetArg("-whiteconnections", 0);
nWhiteConnections = std::max(nUserWhiteConnections, 0);
if ((mapArgs.count("-whitelist")) || (mapArgs.count("-whitebind"))) {
if (!(mapArgs.count("-maxconnections"))) {
// User is using whitelist feature,
// but did not specify -maxconnections parameter.
// Silently increase the default to compensate,
// so that the whitelist connection reservation feature
// does not inadvertently reduce the default
// inbound connection capacity of the network.
nMaxConnections += nWhiteConnections;
}
} else {
// User not using whitelist feature.
// Silently disable connection reservation,
// for the same reason as above.
nWhiteConnections = 0;
}
// Trim requested connection counts, to fit into system limitations // Trim requested connection counts, to fit into system limitations
nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0); nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
@ -784,13 +764,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (nMaxConnections < nUserMaxConnections) if (nMaxConnections < nUserMaxConnections)
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections)); InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
// Connection capacity is prioritized in this order:
// outbound connections (hardcoded to 8),
// then whitelisted connections,
// then non-whitelisted connections get whatever's left (if any).
if ((nWhiteConnections > 0) && (nWhiteConnections >= (nMaxConnections - 8)))
InitWarning(strprintf(_("All non-whitelisted incoming connections will be dropped, because -whiteconnections is %d and -maxconnections is only %d."), nWhiteConnections, nMaxConnections));
// ********************************************************* Step 3: parameter-to-internal-flags // ********************************************************* Step 3: parameter-to-internal-flags
fDebug = !mapMultiArgs["-debug"].empty(); fDebug = !mapMultiArgs["-debug"].empty();
@ -968,8 +941,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("Using data directory %s\n", strDataDir); LogPrintf("Using data directory %s\n", strDataDir);
LogPrintf("Using config file %s\n", GetConfigFile().string()); LogPrintf("Using config file %s\n", GetConfigFile().string());
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD); LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
if (nWhiteConnections > 0)
LogPrintf("Reserving %i of these connections for whitelisted inbound peers\n", nWhiteConnections);
std::ostringstream strErrors; std::ostringstream strErrors;
LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads); LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads);

1
src/net.cpp

@ -81,7 +81,6 @@ uint64_t nLocalHostNonce = 0;
static std::vector<ListenSocket> vhListenSocket; static std::vector<ListenSocket> vhListenSocket;
CAddrMan addrman; CAddrMan addrman;
int nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS; int nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS;
int nWhiteConnections = 0;
bool fAddressesInitialized = false; bool fAddressesInitialized = false;
std::string strSubVersion; std::string strSubVersion;

11
src/net.h

@ -143,19 +143,8 @@ extern uint64_t nLocalServices;
extern uint64_t nLocalHostNonce; extern uint64_t nLocalHostNonce;
extern CAddrMan addrman; extern CAddrMan addrman;
// The allocation of connections against the maximum allowed (nMaxConnections)
// is prioritized as follows:
// 1st: Outbound connections (MAX_OUTBOUND_CONNECTIONS)
// 2nd: Inbound connections from whitelisted peers (nWhiteConnections)
// 3rd: Inbound connections from non-whitelisted peers
// Thus, the number of connection slots for the general public to use is:
// nMaxConnections - (MAX_OUTBOUND_CONNECTIONS + nWhiteConnections)
// Any additional inbound connections beyond limits will be immediately closed
/** Maximum number of connections to simultaneously allow (aka connection slots) */ /** Maximum number of connections to simultaneously allow (aka connection slots) */
extern int nMaxConnections; extern int nMaxConnections;
/** Number of connection slots to reserve for inbound from whitelisted peers */
extern int nWhiteConnections;
extern std::vector<CNode*> vNodes; extern std::vector<CNode*> vNodes;
extern CCriticalSection cs_vNodes; extern CCriticalSection cs_vNodes;

Loading…
Cancel
Save