Remove socks4 support
[novacoin.git] / src / init.cpp
index 50a79ac..4b64d35 100644 (file)
@@ -11,7 +11,6 @@
 #include "ipcollector.h"
 #include "ui_interface.h"
 #include "checkpoints.h"
-#include <boost/format.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/fstream.hpp>
 #include <boost/filesystem/convenience.hpp>
@@ -81,7 +80,7 @@ void Shutdown(void* parg)
             fTaken = true;
         }
     }
-    static bool fExit;
+    volatile static bool fExit;
     if (fFirstThread)
     {
         fShutdown = true;
@@ -240,8 +239,7 @@ std::string HelpMessage()
         "  -dbcache=<n>           " + _("Set database cache size in megabytes (default: 25)") + "\n" +
         "  -dblogsize=<n>         " + _("Set database disk log size in megabytes (default: 100)") + "\n" +
         "  -timeout=<n>           " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" +
-        "  -proxy=<ip:port>       " + _("Connect through socks proxy") + "\n" +
-        "  -socks=<n>             " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" +
+        "  -proxy=<ip:port>       " + _("Connect through socks5 proxy") + "\n" +
         "  -tor=<ip:port>         " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n"
         "  -torname=<host.onion>  " + _("Send the specified hidden service name when connecting to Tor nodes (default: none)") + "\n"
         "  -dns                   " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" +
@@ -269,7 +267,7 @@ std::string HelpMessage()
 #endif
 
         "  -paytxfee=<amt>        " + _("Fee per KB to add to transactions you send") + "\n" +
-        "  -mininput=<amt>        " + str(boost::format(_("When creating transactions, ignore inputs with value less than this (default: %s)")) % FormatMoney(MIN_TXOUT_AMOUNT)) + "\n" +
+        "  -mininput=<amt>        " + ((string)("When creating transactions, ignore inputs with value less than this (default: ") + FormatMoney(MIN_TXOUT_AMOUNT) + ")") + "\n" +
 #ifdef QT_GUI
         "  -server                " + _("Accept command line and JSON-RPC commands") + "\n" +
 #endif
@@ -342,16 +340,15 @@ bool DropBlockIndex()
         }
         return true;
     }
-    catch(std::exception &e)
+    catch(const std::exception&)
     {
         // TODO: report error here
         return false;
     }
 }
 
-/** Initialize bitcoin.
- *  @pre Parameters should be parsed and config file should be read.
- */
+// Initialize bitcoin.
+//  @pre Parameters should be parsed and config file should be read.
 bool AppInit2()
 {
     // ********************************************************* Step 1: setup
@@ -413,19 +410,19 @@ bool AppInit2()
     // Ping and address broadcast intervals
     nPingInterval = max<int64_t>(10 * 60, GetArg("-keepalive", 30 * 60));
 
-    CheckpointsMode = Checkpoints::STRICT;
+    CheckpointsMode = Checkpoints::CP_STRICT;
     auto strCpMode = GetArg("-cppolicy", "strict");
 
     if(strCpMode == "strict") {
-        CheckpointsMode = Checkpoints::STRICT;
+        CheckpointsMode = Checkpoints::CP_STRICT;
     }
 
     if(strCpMode == "advisory") {
-        CheckpointsMode = Checkpoints::ADVISORY;
+        CheckpointsMode = Checkpoints::CP_ADVISORY;
     }
 
     if(strCpMode == "permissive") {
-        CheckpointsMode = Checkpoints::PERMISSIVE;
+        CheckpointsMode = Checkpoints::CP_PERMISSIVE;
     }
 
     fTestNet = GetBoolArg("-testnet");
@@ -585,7 +582,6 @@ bool AppInit2()
         printf("Startup time: %s\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
     printf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
     printf("Used data directory %s\n", strDataDir.c_str());
-    std::ostringstream strErrors;
 
     if (fDaemon)
         fprintf(stdout, "NovaCoin server starting\n");
@@ -596,8 +592,6 @@ bool AppInit2()
             NewThread(ThreadScriptCheck, NULL);
     }
 
-    int64_t nStart;
-
     // ********************************************************* Step 5: verify database integrity
 
     uiInterface.InitMessage(_("Verifying database integrity..."));
@@ -634,11 +628,6 @@ bool AppInit2()
 
     // ********************************************************* Step 6: network initialization
 
-    int nSocksVersion = GetArgInt("-socks", 5);
-
-    if (nSocksVersion != 4 && nSocksVersion != 5)
-        return InitError(strprintf(_("Unknown -socks proxy version requested: %i"), nSocksVersion));
-
     if (mapArgs.count("-onlynet")) {
         std::set<enum Network> nets;
         for(std::string snet :  mapMultiArgs["-onlynet"]) {
@@ -668,14 +657,12 @@ bool AppInit2()
             return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str()));
 
         if (!IsLimited(NET_IPV4))
-            SetProxy(NET_IPV4, addrProxy, nSocksVersion);
-        if (nSocksVersion > 4) {
+            SetProxy(NET_IPV4, addrProxy);
 #ifdef USE_IPV6
             if (!IsLimited(NET_IPV6))
-                SetProxy(NET_IPV6, addrProxy, nSocksVersion);
+                SetProxy(NET_IPV6, addrProxy);
 #endif
-            SetNameProxy(addrProxy, nSocksVersion);
-        }
+            SetNameProxy(addrProxy);
         fProxy = true;
     }
 
@@ -688,7 +675,7 @@ bool AppInit2()
             addrOnion = CService(mapArgs["-tor"], nSocksDefault);
         if (!addrOnion.IsValid())
             return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"].c_str()));
-        SetProxy(NET_TOR, addrOnion, 5);
+        SetProxy(NET_TOR, addrOnion);
         SetReachable(NET_TOR);
     }
 
@@ -709,7 +696,6 @@ bool AppInit2()
     bool fBound = false;
     if (!fNoListen)
     {
-        std::string strError;
         if (mapArgs.count("-bind")) {
             for(std::string strBind :  mapMultiArgs["-bind"]) {
                 CService addrBind;
@@ -796,6 +782,7 @@ bool AppInit2()
 
     printf("Loading block index...\n");
     bool fLoaded = false;
+    int64_t nStart;
     while (!fLoaded) {
         std::string strLoadError;
         uiInterface.InitMessage(_("Loading block index..."));
@@ -847,7 +834,7 @@ bool AppInit2()
         for (auto mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
         {
             auto hash = (*mi).first;
-            if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0)
+            if (strMatch.compare(hash.ToString()) == 0)
             {
                 auto pindex = (*mi).second;
                 CBlock block;
@@ -881,6 +868,7 @@ bool AppInit2()
     uiInterface.InitMessage(_("Loading wallet..."));
     printf("Loading wallet...\n");
     nStart = GetTimeMillis();
+    std::ostringstream strErrors;
     bool fFirstRun = true;
     pwalletMain = new CWallet(strWalletFileName);
     DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun);