Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
#include <boost/bind.hpp> | #include <boost/bind.hpp> | ||||
#include <boost/interprocess/sync/file_lock.hpp> | #include <boost/interprocess/sync/file_lock.hpp> | ||||
#include <boost/thread.hpp> | #include <boost/thread.hpp> | ||||
#if ENABLE_ZMQ | #if ENABLE_ZMQ | ||||
#include "zmq/zmqnotificationinterface.h" | #include "zmq/zmqnotificationinterface.h" | ||||
#endif | #endif | ||||
bool fFeeEstimatesInitialized = false; | |||||
static const bool DEFAULT_PROXYRANDOMIZE = true; | static const bool DEFAULT_PROXYRANDOMIZE = true; | ||||
static const bool DEFAULT_REST_ENABLE = false; | static const bool DEFAULT_REST_ENABLE = false; | ||||
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; | static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; | ||||
std::unique_ptr<CConnman> g_connman; | std::unique_ptr<CConnman> g_connman; | ||||
std::unique_ptr<PeerLogicValidation> peerLogic; | std::unique_ptr<PeerLogicValidation> peerLogic; | ||||
#if !(ENABLE_WALLET) | #if !(ENABLE_WALLET) | ||||
Show All 21 Lines | |||||
#ifdef WIN32 | #ifdef WIN32 | ||||
// Win32 LevelDB doesn't use filedescriptors, and the ones used for accessing | // Win32 LevelDB doesn't use filedescriptors, and the ones used for accessing | ||||
// block files don't count towards the fd_set size limit anyway. | // block files don't count towards the fd_set size limit anyway. | ||||
#define MIN_CORE_FILEDESCRIPTORS 0 | #define MIN_CORE_FILEDESCRIPTORS 0 | ||||
#else | #else | ||||
#define MIN_CORE_FILEDESCRIPTORS 150 | #define MIN_CORE_FILEDESCRIPTORS 150 | ||||
#endif | #endif | ||||
static const char *FEE_ESTIMATES_FILENAME = "fee_estimates.dat"; | |||||
////////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////////// | ||||
// | // | ||||
// Shutdown | // Shutdown | ||||
// | // | ||||
// | // | ||||
// Thread management and startup/shutdown: | // Thread management and startup/shutdown: | ||||
// | // | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | void Shutdown() { | ||||
threadGroup.interrupt_all(); | threadGroup.interrupt_all(); | ||||
threadGroup.join_all(); | threadGroup.join_all(); | ||||
if (fDumpMempoolLater && | if (fDumpMempoolLater && | ||||
gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { | gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { | ||||
DumpMempool(); | DumpMempool(); | ||||
} | } | ||||
if (fFeeEstimatesInitialized) { | |||||
fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; | |||||
CAutoFile est_fileout(fsbridge::fopen(est_path, "wb"), SER_DISK, | |||||
CLIENT_VERSION); | |||||
if (!est_fileout.IsNull()) { | |||||
g_mempool.WriteFeeEstimates(est_fileout); | |||||
} else { | |||||
LogPrintf("%s: Failed to write fee estimates to %s\n", __func__, | |||||
est_path.string()); | |||||
} | |||||
fFeeEstimatesInitialized = false; | |||||
} | |||||
// FlushStateToDisk generates a SetBestChain callback, which we should avoid | // FlushStateToDisk generates a SetBestChain callback, which we should avoid | ||||
// missing | // missing | ||||
if (pcoinsTip != nullptr) { | if (pcoinsTip != nullptr) { | ||||
FlushStateToDisk(); | FlushStateToDisk(); | ||||
} | } | ||||
// After there are no more peers/RPC left to give us new data which may | // After there are no more peers/RPC left to give us new data which may | ||||
// generate CValidationInterface callbacks, flush them... | // generate CValidationInterface callbacks, flush them... | ||||
▲ Show 20 Lines • Show All 1,985 Lines • ▼ Show 20 Lines | #endif | ||||
// As the program has not fully started yet, Shutdown() is possibly | // As the program has not fully started yet, Shutdown() is possibly | ||||
// overkill. | // overkill. | ||||
if (fRequestShutdown) { | if (fRequestShutdown) { | ||||
LogPrintf("Shutdown requested. Exiting.\n"); | LogPrintf("Shutdown requested. Exiting.\n"); | ||||
return false; | return false; | ||||
} | } | ||||
LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart); | LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart); | ||||
fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; | |||||
CAutoFile est_filein(fsbridge::fopen(est_path, "rb"), SER_DISK, | |||||
CLIENT_VERSION); | |||||
// Allowed to fail as this file IS missing on first startup. | |||||
if (!est_filein.IsNull()) { | |||||
g_mempool.ReadFeeEstimates(est_filein); | |||||
} | |||||
fFeeEstimatesInitialized = true; | |||||
// Encoded addresses using cashaddr instead of base58 | // Encoded addresses using cashaddr instead of base58 | ||||
// Activates by default on Jan, 14 | // Activates by default on Jan, 14 | ||||
config.SetCashAddrEncoding( | config.SetCashAddrEncoding( | ||||
gArgs.GetBoolArg("-usecashaddr", GetAdjustedTime() > 1515900000)); | gArgs.GetBoolArg("-usecashaddr", GetAdjustedTime() > 1515900000)); | ||||
// Step 8: load wallet | // Step 8: load wallet | ||||
if (!g_wallet_init_interface->Open(chainparams)) { | if (!g_wallet_init_interface->Open(chainparams)) { | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |