Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
#ifndef WIN32 | #ifndef WIN32 | ||||
#include <attributes.h> | #include <attributes.h> | ||||
#include <cerrno> | #include <cerrno> | ||||
#include <csignal> | #include <csignal> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#endif | #endif | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <cstdio> | #include <cstdio> | ||||
#include <set> | |||||
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; | ||||
#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. | ||||
▲ Show 20 Lines • Show All 1,474 Lines • ▼ Show 20 Lines | |||||
namespace { // Variables internal to initialization process only | namespace { // Variables internal to initialization process only | ||||
int nMaxConnections; | int nMaxConnections; | ||||
int nUserMaxConnections; | int nUserMaxConnections; | ||||
int nFD; | int nFD; | ||||
ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK | NODE_NETWORK_LIMITED); | ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK | NODE_NETWORK_LIMITED); | ||||
int64_t peer_connect_timeout; | int64_t peer_connect_timeout; | ||||
std::vector<BlockFilterType> g_enabled_filter_types; | std::set<BlockFilterType> g_enabled_filter_types; | ||||
} // namespace | } // namespace | ||||
[[noreturn]] static void new_handler_terminate() { | [[noreturn]] static void new_handler_terminate() { | ||||
// Rather than throwing std::bad-alloc if allocation fails, terminate | // Rather than throwing std::bad-alloc if allocation fails, terminate | ||||
// immediately to (try to) avoid chain corruption. Since LogPrintf may | // immediately to (try to) avoid chain corruption. Since LogPrintf may | ||||
// itself allocate memory, set the handler directly to terminate first. | // itself allocate memory, set the handler directly to terminate first. | ||||
std::set_new_handler(std::terminate); | std::set_new_handler(std::terminate); | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | bool AppInitParameterInteraction(Config &config) { | ||||
// parse and validate enabled filter types | // parse and validate enabled filter types | ||||
std::string blockfilterindex_value = | std::string blockfilterindex_value = | ||||
gArgs.GetArg("-blockfilterindex", DEFAULT_BLOCKFILTERINDEX); | gArgs.GetArg("-blockfilterindex", DEFAULT_BLOCKFILTERINDEX); | ||||
if (blockfilterindex_value == "" || blockfilterindex_value == "1") { | if (blockfilterindex_value == "" || blockfilterindex_value == "1") { | ||||
g_enabled_filter_types = AllBlockFilterTypes(); | g_enabled_filter_types = AllBlockFilterTypes(); | ||||
} else if (blockfilterindex_value != "0") { | } else if (blockfilterindex_value != "0") { | ||||
const std::vector<std::string> names = | const std::vector<std::string> names = | ||||
gArgs.GetArgs("-blockfilterindex"); | gArgs.GetArgs("-blockfilterindex"); | ||||
g_enabled_filter_types.reserve(names.size()); | |||||
for (const auto &name : names) { | for (const auto &name : names) { | ||||
BlockFilterType filter_type; | BlockFilterType filter_type; | ||||
if (!BlockFilterTypeByName(name, filter_type)) { | if (!BlockFilterTypeByName(name, filter_type)) { | ||||
return InitError( | return InitError( | ||||
strprintf(_("Unknown -blockfilterindex value %s."), name)); | strprintf(_("Unknown -blockfilterindex value %s."), name)); | ||||
} | } | ||||
g_enabled_filter_types.push_back(filter_type); | g_enabled_filter_types.insert(filter_type); | ||||
} | } | ||||
} | } | ||||
// if using block pruning, then disallow txindex | // if using block pruning, then disallow txindex | ||||
if (gArgs.GetArg("-prune", 0)) { | if (gArgs.GetArg("-prune", 0)) { | ||||
if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | ||||
return InitError(_("Prune mode is incompatible with -txindex.")); | return InitError(_("Prune mode is incompatible with -txindex.")); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,127 Lines • Show Last 20 Lines |