fTaken = true;
}
}
- static bool fExit;
+ volatile static bool fExit;
if (fFirstThread)
{
fShutdown = true;
" -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n" +
" -zapwallettxes " + _("Clear list of wallet transactions (diagnostic tool; implies -rescan)") + "\n" +
" -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n" +
- " -checkblocks=<n> " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n" +
+ " -checkblocks=<n> " + _("How many blocks to check at startup (default: 192, 0 = all)") + "\n" +
" -checklevel=<n> " + _("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=<file> " + _("Imports blocks from external blk000?.dat file") + "\n" +
return strUsage;
}
-/** Initialize bitcoin.
- * @pre Parameters should be parsed and config file should be read.
- */
+bool DropBlockIndex()
+{
+ try
+ {
+#ifdef USE_LEVELDB
+ filesystem::path directory = GetDataDir() / "txleveldb";
+ filesystem::remove_all(directory); // remove directory
+#else
+ filesystem::path indexFile = GetDataDir() / "blkindex.dat";
+ filesystem::remove(indexFile); // remove index file
+#endif
+
+ unsigned int nFile = 1;
+ for ( ; ; )
+ {
+ filesystem::path strBlockFile = GetDataDir() / strprintf("blk%04u.dat", nFile);
+ // Break if no such file
+ if( !filesystem::exists( strBlockFile ) )
+ break;
+ filesystem::remove(strBlockFile);
+ nFile++;
+ }
+ return true;
+ }
+ catch(const std::exception&)
+ {
+ // TODO: report error here
+ return false;
+ }
+}
+
+// Initialize bitcoin.
+// @pre Parameters should be parsed and config file should be read.
bool AppInit2()
{
// ********************************************************* Step 1: setup
// 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");
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
nScriptCheckThreads = GetArgInt("-par", 0);
if (nScriptCheckThreads == 0)
- nScriptCheckThreads = std::thread::hardware_concurrency();
+ nScriptCheckThreads = boost::thread::hardware_concurrency();
if (nScriptCheckThreads <= 1)
nScriptCheckThreads = 0;
else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS)
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");
NewThread(ThreadScriptCheck, NULL);
}
- int64_t nStart;
-
// ********************************************************* Step 5: verify database integrity
uiInterface.InitMessage(_("Verifying database integrity..."));
bool fBound = false;
if (!fNoListen)
{
- std::string strError;
if (mapArgs.count("-bind")) {
for(std::string strBind : mapMultiArgs["-bind"]) {
CService addrBind;
printf("Loading block index...\n");
bool fLoaded = false;
+ int64_t nStart;
while (!fLoaded) {
std::string strLoadError;
uiInterface.InitMessage(_("Loading block index..."));
} while(false);
if (!fLoaded) {
+ DropBlockIndex();
// TODO: suggest reindex here
return InitError(strLoadError);
}
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;
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);
{
FILE *file = fopen(strFile.c_str(), "rb");
if (file)
- LoadExternalBlockFile(file);
+ LoadExternalBlockFile(file, uiInterface);
}
StartShutdown();
}
FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
if (file) {
filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
- LoadExternalBlockFile(file);
+ LoadExternalBlockFile(file, uiInterface);
RenameOver(pathBootstrap, pathBootstrapOld);
}
}