Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
Lint: Code style violation: '/home/jimpo/Code/github.com/Bitcoin-ABC/bitcoin-abc/src/init.cpp' has code style errors. | |||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include "config/bitcoin-config.h" | #include "config/bitcoin-config.h" | ||||
#endif | #endif | ||||
#include "init.h" | #include "init.h" | ||||
#include "addrman.h" | #include "addrman.h" | ||||
#include "amount.h" | #include "amount.h" | ||||
#include "chain.h" | #include "chain.h" | ||||
#include "chainparams.h" | #include "chainparams.h" | ||||
#include "checkpoints.h" | #include "checkpoints.h" | ||||
#include "compat/sanity.h" | #include "compat/sanity.h" | ||||
#include "config.h" | #include "config.h" | ||||
#include "consensus/validation.h" | #include "consensus/validation.h" | ||||
#include "fs.h" | #include "fs.h" | ||||
#include "httprpc.h" | #include "httprpc.h" | ||||
#include "httpserver.h" | #include "httpserver.h" | ||||
#include "key.h" | #include "key.h" | ||||
#include "logging.h" | |||||
#include "miner.h" | #include "miner.h" | ||||
#include "net.h" | #include "net.h" | ||||
#include "net_processing.h" | #include "net_processing.h" | ||||
#include "netbase.h" | #include "netbase.h" | ||||
#include "policy/policy.h" | #include "policy/policy.h" | ||||
#include "rpc/register.h" | #include "rpc/register.h" | ||||
#include "rpc/server.h" | #include "rpc/server.h" | ||||
#include "scheduler.h" | #include "scheduler.h" | ||||
▲ Show 20 Lines • Show All 1,195 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void InitLogging() { | void InitLogging() { | ||||
fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", false); | fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", false); | ||||
fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS); | fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS); | ||||
fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS); | fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS); | ||||
fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS); | fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS); | ||||
g_logger.reset(new BCLog::Logger()); | |||||
g_logger->log_timestamps = fLogTimestamps; | |||||
g_logger->log_time_micros = fLogTimeMicros; | |||||
// TODO: logthreadid, loglevel | |||||
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); | LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); | ||||
LogPrintf("%s version %s\n", CLIENT_NAME, FormatFullVersion()); | LogPrintf("%s version %s\n", CLIENT_NAME, FormatFullVersion()); | ||||
} | } | ||||
namespace { // Variables internal to initialization process only | namespace { // Variables internal to initialization process only | ||||
ServiceFlags nRelevantServices = NODE_NETWORK; | ServiceFlags nRelevantServices = NODE_NETWORK; | ||||
int nMaxConnections; | int nMaxConnections; | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | bool AppInitParameterInteraction(Config &config) { | ||||
if (nMaxConnections < nUserMaxConnections) { | if (nMaxConnections < nUserMaxConnections) { | ||||
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, " | InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, " | ||||
"because of system limitations."), | "because of system limitations."), | ||||
nUserMaxConnections, nMaxConnections)); | nUserMaxConnections, nMaxConnections)); | ||||
} | } | ||||
// Step 3: parameter-to-internal-flags | // Step 3: parameter-to-internal-flags | ||||
uint32_t log_flags = 0; | |||||
if (gArgs.IsArgSet("-debug")) { | if (gArgs.IsArgSet("-debug")) { | ||||
// Special-case: if -debug=0/-nodebug is set, turn off debugging | // Special-case: if -debug=0/-nodebug is set, turn off debugging | ||||
// messages | // messages | ||||
const std::vector<std::string> &categories = gArgs.GetArgs("-debug"); | const std::vector<std::string> &categories = gArgs.GetArgs("-debug"); | ||||
if (find(categories.begin(), categories.end(), std::string("0")) == | if (find(categories.begin(), categories.end(), std::string("0")) == | ||||
categories.end()) { | categories.end()) { | ||||
for (const auto &cat : categories) { | for (const auto &cat : categories) { | ||||
uint32_t flag = 0; | uint32_t flag = 0; | ||||
if (!GetLogCategory(&flag, &cat)) { | if (!GetLogCategory(&flag, &cat)) { | ||||
InitWarning( | InitWarning( | ||||
strprintf(_("Unsupported logging category %s=%s."), | strprintf(_("Unsupported logging category %s=%s."), | ||||
"-debug", cat)); | "-debug", cat)); | ||||
} | } | ||||
logCategories |= flag; | log_flags |= flag; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Now remove the logging categories which were explicitly excluded | // Now remove the logging categories which were explicitly excluded | ||||
if (gArgs.IsArgSet("-debugexclude")) { | if (gArgs.IsArgSet("-debugexclude")) { | ||||
for (const std::string &cat : gArgs.GetArgs("-debugexclude")) { | for (const std::string &cat : gArgs.GetArgs("-debugexclude")) { | ||||
uint32_t flag; | uint32_t flag; | ||||
if (!GetLogCategory(&flag, &cat)) { | if (!GetLogCategory(&flag, &cat)) { | ||||
InitWarning(strprintf(_("Unsupported logging category %s=%s."), | InitWarning(strprintf(_("Unsupported logging category %s=%s."), | ||||
"-debugexclude", cat)); | "-debugexclude", cat)); | ||||
} | } | ||||
logCategories &= ~flag; | log_flags &= ~flag; | ||||
} | } | ||||
} | } | ||||
// Assign configured log categories to global logger. | |||||
logCategories.store(log_flags); | |||||
if (g_logger) g_logger->categories = static_cast<BCLog::LogFlags>(log_flags); | |||||
// Check for -debugnet | // Check for -debugnet | ||||
if (gArgs.GetBoolArg("-debugnet", false)) | if (gArgs.GetBoolArg("-debugnet", false)) | ||||
InitWarning( | InitWarning( | ||||
_("Unsupported argument -debugnet ignored, use -debug=net.")); | _("Unsupported argument -debugnet ignored, use -debug=net.")); | ||||
// Check for -socks - as this is a privacy risk to continue, exit here | // Check for -socks - as this is a privacy risk to continue, exit here | ||||
if (gArgs.IsArgSet("-socks")) | if (gArgs.IsArgSet("-socks")) | ||||
return InitError( | return InitError( | ||||
_("Unsupported argument -socks found. Setting SOCKS version isn't " | _("Unsupported argument -socks found. Setting SOCKS version isn't " | ||||
▲ Show 20 Lines • Show All 874 Lines • ▼ Show 20 Lines | if (!connman.Start(scheduler, strNodeError, connOptions)) { | ||||
return InitError(strNodeError); | return InitError(strNodeError); | ||||
} | } | ||||
// Step 12: finished | // Step 12: finished | ||||
SetRPCWarmupFinished(); | SetRPCWarmupFinished(); | ||||
uiInterface.InitMessage(_("Done loading")); | uiInterface.InitMessage(_("Done loading")); | ||||
LOG(INFO, ALL).Message("Done with init %d", 5); | |||||
LOG(INFO, NET) | |||||
.Message("There's net code happening") | |||||
.With("ip_address", "1.2.3.4"); | |||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
for (CWalletRef pwallet : vpwallets) { | for (CWalletRef pwallet : vpwallets) { | ||||
pwallet->postInitProcess(scheduler); | pwallet->postInitProcess(scheduler); | ||||
} | } | ||||
#endif | #endif | ||||
return !fRequestShutdown; | return !fRequestShutdown; | ||||
} | } |
'/home/jimpo/Code/github.com/Bitcoin-ABC/bitcoin-abc/src/init.cpp' has code style errors.