|
|
@ -47,6 +47,7 @@ using namespace std; |
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
CWallet* pwalletMain; |
|
|
|
CWallet* pwalletMain; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
bool fFeeEstimatesInitialized = false; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32 |
|
|
|
#ifdef WIN32 |
|
|
|
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
|
|
|
|
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
|
|
|
@ -119,6 +120,10 @@ void Shutdown() |
|
|
|
if (!lockShutdown) |
|
|
|
if (!lockShutdown) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Note: Shutdown() must be able to handle cases in which AppInit2() failed part of the way,
|
|
|
|
|
|
|
|
/// for example if the data directory was found to be locked.
|
|
|
|
|
|
|
|
/// Be sure that anything that writes files or flushes caches only does this if the respective
|
|
|
|
|
|
|
|
/// module was initialized.
|
|
|
|
RenameThread("bitcoin-shutoff"); |
|
|
|
RenameThread("bitcoin-shutoff"); |
|
|
|
mempool.AddTransactionsUpdated(1); |
|
|
|
mempool.AddTransactionsUpdated(1); |
|
|
|
StopRPCThreads(); |
|
|
|
StopRPCThreads(); |
|
|
@ -130,6 +135,7 @@ void Shutdown() |
|
|
|
StopNode(); |
|
|
|
StopNode(); |
|
|
|
UnregisterNodeSignals(GetNodeSignals()); |
|
|
|
UnregisterNodeSignals(GetNodeSignals()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fFeeEstimatesInitialized) |
|
|
|
{ |
|
|
|
{ |
|
|
|
boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; |
|
|
|
boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; |
|
|
|
CAutoFile est_fileout(fopen(est_path.string().c_str(), "wb"), SER_DISK, CLIENT_VERSION); |
|
|
|
CAutoFile est_fileout(fopen(est_path.string().c_str(), "wb"), SER_DISK, CLIENT_VERSION); |
|
|
@ -137,6 +143,7 @@ void Shutdown() |
|
|
|
mempool.WriteFeeEstimates(est_fileout); |
|
|
|
mempool.WriteFeeEstimates(est_fileout); |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrintf("%s: Failed to write fee estimates to %s\n", __func__, est_path.string()); |
|
|
|
LogPrintf("%s: Failed to write fee estimates to %s\n", __func__, est_path.string()); |
|
|
|
|
|
|
|
fFeeEstimatesInitialized = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
@ -1056,6 +1063,7 @@ bool AppInit2(boost::thread_group& threadGroup) |
|
|
|
// Allowed to fail as this file IS missing on first startup.
|
|
|
|
// Allowed to fail as this file IS missing on first startup.
|
|
|
|
if (est_filein) |
|
|
|
if (est_filein) |
|
|
|
mempool.ReadFeeEstimates(est_filein); |
|
|
|
mempool.ReadFeeEstimates(est_filein); |
|
|
|
|
|
|
|
fFeeEstimatesInitialized = true; |
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************* Step 8: load wallet
|
|
|
|
// ********************************************************* Step 8: load wallet
|
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
#ifdef ENABLE_WALLET |
|
|
@ -1212,22 +1220,7 @@ bool AppInit2(boost::thread_group& threadGroup) |
|
|
|
} |
|
|
|
} |
|
|
|
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); |
|
|
|
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); |
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************* Step 10: load peers
|
|
|
|
// ********************************************************* Step 10: start node
|
|
|
|
|
|
|
|
|
|
|
|
uiInterface.InitMessage(_("Loading addresses...")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nStart = GetTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CAddrDB adb; |
|
|
|
|
|
|
|
if (!adb.Read(addrman)) |
|
|
|
|
|
|
|
LogPrintf("Invalid or missing peers.dat; recreating\n"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogPrintf("Loaded %i addresses from peers.dat %dms\n", |
|
|
|
|
|
|
|
addrman.size(), GetTimeMillis() - nStart); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************* Step 11: start node
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!CheckDiskSpace()) |
|
|
|
if (!CheckDiskSpace()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1256,7 +1249,7 @@ bool AppInit2(boost::thread_group& threadGroup) |
|
|
|
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", -1)); |
|
|
|
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", -1)); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************* Step 12: finished
|
|
|
|
// ********************************************************* Step 11: finished
|
|
|
|
|
|
|
|
|
|
|
|
uiInterface.InitMessage(_("Done loading")); |
|
|
|
uiInterface.InitMessage(_("Done loading")); |
|
|
|
|
|
|
|
|
|
|
|