X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Finit.cpp;h=b934e1c567b69460aadb539ab21229056f374cec;hb=24b2f2d42d10153c24ccef4a14ba57ad24aac183;hp=9c65dabb6b5c5fcb6587468be6a741aeac8fa6c0;hpb=273ceadcc0475b03a2be03ffbeded0831d8232fc;p=novacoin.git diff --git a/src/init.cpp b/src/init.cpp index 9c65dab..b934e1c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -10,7 +10,6 @@ #include "util.h" #include "ui_interface.h" #include "checkpoints.h" -#include "zerocoin/ZeroTest.h" #include #include #include @@ -32,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 @@ -86,10 +89,6 @@ void Shutdown(void* parg) nTransactionsUpdated++; // CTxDB().Close(); bitdb.Flush(false); - { - LOCK(cs_main); - ThreadScriptCheckQuit(); - } StopNode(); bitdb.Flush(true); boost::filesystem::remove(GetPidFile()); @@ -271,6 +270,11 @@ 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= " + str(boost::format(_("When creating transactions, ignore inputs with value less than this (default: %s)")) % FormatMoney(MIN_TXOUT_AMOUNT)) + "\n" + #ifdef QT_GUI @@ -370,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) { @@ -497,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)) @@ -553,7 +564,7 @@ bool AppInit2() NewThread(ThreadScriptCheck, NULL); } - int64 nStart; + int64_t nStart; // ********************************************************* Step 5: verify database integrity @@ -650,12 +661,21 @@ bool AppInit2() } // see Step 2: parameter interactions for more information about these - fNoListen = !GetBoolArg("-listen", true); - fDiscover = GetBoolArg("-discover", true); - fNameLookup = GetBoolArg("-dns", true); + if (!IsLimited(NET_IPV4) || !IsLimited(NET_IPV6)) + { + fNoListen = !GetBoolArg("-listen", true); + fDiscover = GetBoolArg("-discover", true); + fNameLookup = GetBoolArg("-dns", true); #ifdef USE_UPNP - fUseUPnP = GetBoolArg("-upnp", USE_UPNP); + fUseUPnP = GetBoolArg("-upnp", USE_UPNP); #endif + } else { + // Don't listen, discover addresses or search for nodes if IPv4 and IPv6 networking is disabled. + fNoListen = true; + fDiscover = fNameLookup = fUseUPnP = false; + SoftSetBoolArg("-irc", false); + SoftSetBoolArg("-dnsseed", false); + } bool fBound = false; if (!fNoListen) @@ -694,7 +714,7 @@ bool AppInit2() if (mapArgs.count("-reservebalance")) // ppcoin: reserve balance amount { - int64 nReserveBalance = 0; + int64_t nReserveBalance = 0; if (!ParseMoney(mapArgs["-reservebalance"], nReserveBalance)) { InitError(_("Invalid amount for -reservebalance=")); @@ -744,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")) { @@ -775,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...")); @@ -845,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); @@ -865,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 @@ -880,7 +890,7 @@ bool AppInit2() if (file) LoadExternalBlockFile(file); } - exit(0); + StartShutdown(); } filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat"; @@ -907,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 @@ -918,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"));