Drop sprintf dependency
[novacoin.git] / src / init.cpp
index 50a79ac..5117dd5 100644 (file)
@@ -81,7 +81,7 @@ void Shutdown(void* parg)
             fTaken = true;
         }
     }
-    static bool fExit;
+    volatile static bool fExit;
     if (fFirstThread)
     {
         fShutdown = true;
@@ -342,16 +342,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 +412,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 +584,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 +594,6 @@ bool AppInit2()
             NewThread(ThreadScriptCheck, NULL);
     }
 
-    int64_t nStart;
-
     // ********************************************************* Step 5: verify database integrity
 
     uiInterface.InitMessage(_("Verifying database integrity..."));
@@ -709,7 +705,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 +791,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 +843,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 +877,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);