X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Finit.cpp;h=b934e1c567b69460aadb539ab21229056f374cec;hb=24b2f2d42d10153c24ccef4a14ba57ad24aac183;hp=66ffda6c96c2bb1f8ecf7cf141d84798550eb230;hpb=63071de429b3e0552ddffee72b0c993a7c4ea6a4;p=novacoin.git diff --git a/src/init.cpp b/src/init.cpp index 66ffda6..b934e1c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -10,7 +10,7 @@ #include "util.h" #include "ui_interface.h" #include "checkpoints.h" -#include "zerocoin/ZeroTest.h" +#include #include #include #include @@ -31,12 +31,16 @@ CClientUIInterface uiInterface; std::string strWalletFileName; bool fConfChange; unsigned int nNodeLifespan; -unsigned int nDerivationMethodIndex; unsigned int nMinerSleep; bool fUseFastIndex; bool fUseFastStakeMiner; +bool fUseMemoryLog; enum Checkpoints::CPMode CheckpointsMode; +// Ping and address broadcast intervals +extern int64_t nPingInterval; +extern int64_t nBroadcastInterval; + ////////////////////////////////////////////////////////////////////////////// // // Shutdown @@ -67,7 +71,7 @@ void Shutdown(void* parg) static bool fTaken; // Make this thread recognisable as the shutdown thread - RenameThread("bitcoin-shutoff"); + RenameThread("novacoin-shutoff"); bool fFirstThread = false; { @@ -233,7 +237,7 @@ std::string HelpMessage() " -conf= " + _("Specify configuration file (default: novacoin.conf)") + "\n" + " -pid= " + _("Specify pid file (default: novacoind.pid)") + "\n" + " -datadir= " + _("Specify data directory") + "\n" + - " -wallet= " + _("Specify wallet file (within data directory)") + "\n" + + " -wallet= " + _("Specify wallet file (within data directory)") + "\n" + " -dbcache= " + _("Set database cache size in megabytes (default: 25)") + "\n" + " -dblogsize= " + _("Set database disk log size in megabytes (default: 100)") + "\n" + " -timeout= " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" + @@ -266,8 +270,13 @@ std::string HelpMessage() #endif #endif " -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" + + +#ifdef DB_LOG_IN_MEMORY + " -memorylog " + _("Use in-memory logging for block index database (default: 1)") + "\n" + +#endif + " -paytxfee= " + _("Fee per KB to add to transactions you send") + "\n" + - " -mininput= " + _("When creating transactions, ignore inputs with value less than this (default: 0.01)") + "\n" + + " -mininput= " + str(boost::format(_("When creating transactions, ignore inputs with value less than this (default: %s)")) % FormatMoney(MIN_TXOUT_AMOUNT)) + "\n" + #ifdef QT_GUI " -server " + _("Accept command line and JSON-RPC commands") + "\n" + #endif @@ -297,6 +306,7 @@ std::string HelpMessage() " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n" + " -checkblocks= " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n" + " -checklevel= " + _("How thorough the block verification is (0-6, default: 1)") + "\n" + + " -par=N " + _("Set the number of script verification threads (1-16, 0=auto, default: 0)") + "\n" + " -loadblock= " + _("Imports blocks from external blk000?.dat file") + "\n" + "\n" + _("Block creation options:") + "\n" + @@ -364,21 +374,28 @@ bool AppInit2() nNodeLifespan = GetArg("-addrlifespan", 7); fUseFastIndex = GetBoolArg("-fastindex", true); + fUseMemoryLog = GetBoolArg("-memorylog", true); nMinerSleep = GetArg("-minersleep", 500); + // Ping and address broadcast intervals + nPingInterval = max(10 * 60, GetArg("-keepalive", 30 * 60)); + + nBroadcastInterval = max(6 * 60 * 60, GetArg("-addrsetlifetime", 24 * 60 * 60)); + CheckpointsMode = Checkpoints::STRICT; std::string strCpMode = GetArg("-cppolicy", "strict"); - if(strCpMode == "strict") + if(strCpMode == "strict") { CheckpointsMode = Checkpoints::STRICT; + } - if(strCpMode == "advisory") + if(strCpMode == "advisory") { CheckpointsMode = Checkpoints::ADVISORY; + } - if(strCpMode == "permissive") + if(strCpMode == "permissive") { CheckpointsMode = Checkpoints::PERMISSIVE; - - nDerivationMethodIndex = 0; + } fTestNet = GetBoolArg("-testnet"); if (fTestNet) { @@ -420,6 +437,15 @@ bool AppInit2() // ********************************************************* Step 3: parameter-to-internal-flags + // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency + nScriptCheckThreads = GetArg("-par", 0); + if (nScriptCheckThreads == 0) + nScriptCheckThreads = boost::thread::hardware_concurrency(); + if (nScriptCheckThreads <= 1) + nScriptCheckThreads = 0; + else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS) + nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS; + fDebug = GetBoolArg("-debug"); // -debug implies fDebug* @@ -482,7 +508,7 @@ bool AppInit2() // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log std::string strDataDir = GetDataDir().string(); - std::string strWalletFileName = GetArg("-wallet", "wallet.dat"); + strWalletFileName = GetArg("-wallet", "wallet.dat"); // strWalletFileName must be a plain filename without a directory if (strWalletFileName != boost::filesystem::basename(strWalletFileName) + boost::filesystem::extension(strWalletFileName)) @@ -532,7 +558,13 @@ bool AppInit2() if (fDaemon) fprintf(stdout, "NovaCoin server starting\n"); - int64 nStart; + if (nScriptCheckThreads) { + printf("Using %u threads for script verification\n", nScriptCheckThreads); + for (int i=0; i")); @@ -723,7 +764,7 @@ bool AppInit2() printf("Shutdown requested. Exiting.\n"); return false; } - printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" block index %15" PRId64 "ms\n", GetTimeMillis() - nStart); if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree")) { @@ -754,16 +795,6 @@ bool AppInit2() return false; } - // ********************************************************* Testing Zerocoin - - - if (GetBoolArg("-zerotest", false)) - { - printf("\n=== ZeroCoin tests start ===\n"); - Test_RunAllTests(); - printf("=== ZeroCoin tests end ===\n\n"); - } - // ********************************************************* Step 8: load wallet uiInterface.InitMessage(_("Loading wallet...")); @@ -824,7 +855,7 @@ bool AppInit2() } printf("%s", strErrors.str().c_str()); - printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" wallet %15" PRId64 "ms\n", GetTimeMillis() - nStart); RegisterWallet(pwalletMain); @@ -844,7 +875,7 @@ bool AppInit2() printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight); nStart = GetTimeMillis(); pwalletMain->ScanForWalletTransactions(pindexRescan, true); - printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" rescan %15" PRId64 "ms\n", GetTimeMillis() - nStart); } // ********************************************************* Step 9: import blocks @@ -859,7 +890,7 @@ bool AppInit2() if (file) LoadExternalBlockFile(file); } - exit(0); + StartShutdown(); } filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat"; @@ -886,7 +917,7 @@ bool AppInit2() printf("Invalid or missing peers.dat; recreating\n"); } - printf("Loaded %i addresses from peers.dat %"PRI64d"ms\n", + printf("Loaded %i addresses from peers.dat %" PRId64 "ms\n", addrman.size(), GetTimeMillis() - nStart); // ********************************************************* Step 11: start node @@ -897,11 +928,11 @@ bool AppInit2() RandAddSeedPerfmon(); //// debug print - printf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size()); + printf("mapBlockIndex.size() = %" PRIszu "\n", mapBlockIndex.size()); printf("nBestHeight = %d\n", nBestHeight); - printf("setKeyPool.size() = %"PRIszu"\n", pwalletMain->setKeyPool.size()); - printf("mapWallet.size() = %"PRIszu"\n", pwalletMain->mapWallet.size()); - printf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain->mapAddressBook.size()); + printf("setKeyPool.size() = %" PRIszu "\n", pwalletMain->setKeyPool.size()); + printf("mapWallet.size() = %" PRIszu "\n", pwalletMain->mapWallet.size()); + printf("mapAddressBook.size() = %" PRIszu "\n", pwalletMain->mapAddressBook.size()); if (!NewThread(StartNode, NULL)) InitError(_("Error: could not start node"));