Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
#include <boost/algorithm/string/classification.hpp> | #include <boost/algorithm/string/classification.hpp> | ||||
#include <boost/algorithm/string/replace.hpp> | #include <boost/algorithm/string/replace.hpp> | ||||
#include <boost/algorithm/string/split.hpp> | #include <boost/algorithm/string/split.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> | ||||
#include <zmq/zmqrpc.h> | |||||
#endif | #endif | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
#include <csignal> | #include <csignal> | ||||
#endif | #endif | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <cstdio> | #include <cstdio> | ||||
#include <memory> | #include <memory> | ||||
Show All 24 Lines | public: | ||||
void Flush() const override {} | void Flush() const override {} | ||||
void Stop() const override {} | void Stop() const override {} | ||||
void Close() const override {} | void Close() const override {} | ||||
}; | }; | ||||
const WalletInitInterface &g_wallet_init_interface = DummyWalletInit(); | const WalletInitInterface &g_wallet_init_interface = DummyWalletInit(); | ||||
#endif | #endif | ||||
#if ENABLE_ZMQ | |||||
static CZMQNotificationInterface *pzmqNotificationInterface = nullptr; | |||||
#endif | |||||
#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 | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | // cases and make next startup faster by avoiding rescan. | ||||
pcoinsTip.reset(); | pcoinsTip.reset(); | ||||
pcoinscatcher.reset(); | pcoinscatcher.reset(); | ||||
pcoinsdbview.reset(); | pcoinsdbview.reset(); | ||||
pblocktree.reset(); | pblocktree.reset(); | ||||
} | } | ||||
g_wallet_init_interface.Stop(); | g_wallet_init_interface.Stop(); | ||||
#if ENABLE_ZMQ | #if ENABLE_ZMQ | ||||
if (pzmqNotificationInterface) { | if (g_zmq_notification_interface) { | ||||
UnregisterValidationInterface(pzmqNotificationInterface); | UnregisterValidationInterface(g_zmq_notification_interface); | ||||
delete pzmqNotificationInterface; | delete g_zmq_notification_interface; | ||||
pzmqNotificationInterface = nullptr; | g_zmq_notification_interface = nullptr; | ||||
} | } | ||||
#endif | #endif | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
try { | try { | ||||
fs::remove(GetPidFile()); | fs::remove(GetPidFile()); | ||||
} catch (const fs::filesystem_error &e) { | } catch (const fs::filesystem_error &e) { | ||||
LogPrintf("%s: Unable to remove pidfile: %s\n", __func__, e.what()); | LogPrintf("%s: Unable to remove pidfile: %s\n", __func__, e.what()); | ||||
▲ Show 20 Lines • Show All 1,635 Lines • ▼ Show 20 Lines | #endif | ||||
GetMainSignals().RegisterWithMempoolSignals(g_mempool); | GetMainSignals().RegisterWithMempoolSignals(g_mempool); | ||||
/** | /** | ||||
* Register RPC commands regardless of -server setting so they will be | * Register RPC commands regardless of -server setting so they will be | ||||
* available in the GUI RPC console even if external calls are disabled. | * available in the GUI RPC console even if external calls are disabled. | ||||
*/ | */ | ||||
RegisterAllRPCCommands(config, rpcServer, tableRPC); | RegisterAllRPCCommands(config, rpcServer, tableRPC); | ||||
g_wallet_init_interface.RegisterRPC(tableRPC); | g_wallet_init_interface.RegisterRPC(tableRPC); | ||||
#if ENABLE_ZMQ | |||||
RegisterZMQRPCCommands(tableRPC); | |||||
#endif | |||||
/** | /** | ||||
* Start the RPC server. It will be started in "warmup" mode and not | * Start the RPC server. It will be started in "warmup" mode and not | ||||
* process calls yet (but it will verify that the server is there and will | * process calls yet (but it will verify that the server is there and will | ||||
* be ready later). Warmup mode will be completed when initialisation is | * be ready later). Warmup mode will be completed when initialisation is | ||||
* finished. | * finished. | ||||
*/ | */ | ||||
if (gArgs.GetBoolArg("-server", false)) { | if (gArgs.GetBoolArg("-server", false)) { | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | for (const std::string &strAddr : gArgs.GetArgs("-externalip")) { | ||||
addrLocal.IsValid()) { | addrLocal.IsValid()) { | ||||
AddLocal(addrLocal, LOCAL_MANUAL); | AddLocal(addrLocal, LOCAL_MANUAL); | ||||
} else { | } else { | ||||
return InitError(ResolveErrMsg("externalip", strAddr)); | return InitError(ResolveErrMsg("externalip", strAddr)); | ||||
} | } | ||||
} | } | ||||
#if ENABLE_ZMQ | #if ENABLE_ZMQ | ||||
pzmqNotificationInterface = CZMQNotificationInterface::Create(); | g_zmq_notification_interface = CZMQNotificationInterface::Create(); | ||||
if (pzmqNotificationInterface) { | if (g_zmq_notification_interface) { | ||||
RegisterValidationInterface(pzmqNotificationInterface); | RegisterValidationInterface(g_zmq_notification_interface); | ||||
} | } | ||||
#endif | #endif | ||||
// unlimited unless -maxuploadtarget is set | // unlimited unless -maxuploadtarget is set | ||||
uint64_t nMaxOutboundLimit = 0; | uint64_t nMaxOutboundLimit = 0; | ||||
uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME; | uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME; | ||||
if (gArgs.IsArgSet("-maxuploadtarget")) { | if (gArgs.IsArgSet("-maxuploadtarget")) { | ||||
nMaxOutboundLimit = | nMaxOutboundLimit = | ||||
▲ Show 20 Lines • Show All 435 Lines • Show Last 20 Lines |