Browse Source

add -timeout default as constant and use them

- update help message text
- simplify code in init to check for -timeout
0.10
Philip Kaufmann 10 years ago
parent
commit
de10efd154
  1. 11
      src/init.cpp
  2. 2
      src/netbase.cpp
  3. 3
      src/netbase.h

11
src/init.cpp

@ -260,7 +260,7 @@ std::string HelpMessage(HelpMessageMode mode) @@ -260,7 +260,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " -port=<port> " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n";
strUsage += " -proxy=<ip:port> " + _("Connect through SOCKS5 proxy") + "\n";
strUsage += " -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n";
strUsage += " -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n";
strUsage += " -timeout=<n> " + strprintf(_("Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT) + "\n";
#ifdef USE_UPNP
#if USE_UPNP
strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n";
@ -641,12 +641,9 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -641,12 +641,9 @@ bool AppInit2(boost::thread_group& threadGroup)
bool fDisableWallet = GetBoolArg("-disablewallet", false);
#endif
if (mapArgs.count("-timeout"))
{
int nNewTimeout = GetArg("-timeout", 5000);
if (nNewTimeout > 0 && nNewTimeout < 600000)
nConnectTimeout = nNewTimeout;
}
nConnectTimeout = GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
if (nConnectTimeout <= 0)
nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
// Continue to put "/P2SH/" in the coinbase to monitor
// BIP16 support.

2
src/netbase.cpp

@ -40,7 +40,7 @@ using namespace std; @@ -40,7 +40,7 @@ using namespace std;
static proxyType proxyInfo[NET_MAX];
static CService nameProxy;
static CCriticalSection cs_proxyInfos;
int nConnectTimeout = 5000;
int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
bool fNameLookup = false;
static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };

3
src/netbase.h

@ -19,6 +19,9 @@ @@ -19,6 +19,9 @@
extern int nConnectTimeout;
extern bool fNameLookup;
/** -timeout default */
static const int DEFAULT_CONNECT_TIMEOUT = 5000;
#ifdef WIN32
// In MSVC, this is defined as a macro, undefine it to prevent a compile and link error
#undef SetPort

Loading…
Cancel
Save