Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 367 Lines • ▼ Show 20 Lines | void SetupServerArgs() { | ||||
// When adding new options to the categories, please keep and ensure | // When adding new options to the categories, please keep and ensure | ||||
// alphabetical ordering. Do not translate _(...) -help-debug options, Many | // alphabetical ordering. Do not translate _(...) -help-debug options, Many | ||||
// technical terms, and only a very small audience, so is unnecessary stress | // technical terms, and only a very small audience, so is unnecessary stress | ||||
// to translators. | // to translators. | ||||
gArgs.AddArg("-?", "Print this help message and exit", | gArgs.AddArg("-?", "Print this help message and exit", | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, | gArgs.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, | ||||
OptionsCategory::OPTIONS); | OptionsCategory::OPTIONS); | ||||
#if defined(HAVE_SYSTEM) | |||||
gArgs.AddArg("-alertnotify=<cmd>", | gArgs.AddArg("-alertnotify=<cmd>", | ||||
"Execute command when a relevant alert is received or we see " | "Execute command when a relevant alert is received or we see " | ||||
"a really long fork (%s in cmd is replaced by message)", | "a really long fork (%s in cmd is replaced by message)", | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ||||
#endif | |||||
gArgs.AddArg( | gArgs.AddArg( | ||||
"-assumevalid=<hex>", | "-assumevalid=<hex>", | ||||
strprintf( | strprintf( | ||||
"If this block is in the chain assume that it and its ancestors " | "If this block is in the chain assume that it and its ancestors " | ||||
"are valid and potentially skip their script verification (0 to " | "are valid and potentially skip their script verification (0 to " | ||||
"verify all, default: %s, testnet: %s)", | "verify all, default: %s, testnet: %s)", | ||||
defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), | defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), | ||||
testnetChainParams->GetConsensus().defaultAssumeValid.GetHex()), | testnetChainParams->GetConsensus().defaultAssumeValid.GetHex()), | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-blocksdir=<dir>", | gArgs.AddArg("-blocksdir=<dir>", | ||||
"Specify directory to hold blocks subdirectory for *.dat " | "Specify directory to hold blocks subdirectory for *.dat " | ||||
"files (default: <datadir>)", | "files (default: <datadir>)", | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ||||
#if defined(HAVE_SYSTEM) | |||||
gArgs.AddArg("-blocknotify=<cmd>", | gArgs.AddArg("-blocknotify=<cmd>", | ||||
"Execute command when the best block changes (%s in cmd is " | "Execute command when the best block changes (%s in cmd is " | ||||
"replaced by block hash)", | "replaced by block hash)", | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ||||
#endif | |||||
gArgs.AddArg("-blockreconstructionextratxn=<n>", | gArgs.AddArg("-blockreconstructionextratxn=<n>", | ||||
strprintf("Extra transactions to keep in memory for compact " | strprintf("Extra transactions to keep in memory for compact " | ||||
"block reconstructions (default: %u)", | "block reconstructions (default: %u)", | ||||
DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN), | DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN), | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg( | gArgs.AddArg( | ||||
"-blocksonly", | "-blocksonly", | ||||
strprintf( | strprintf( | ||||
▲ Show 20 Lines • Show All 762 Lines • ▼ Show 20 Lines | return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, | ||||
"OpenSSL Project for use in the OpenSSL Toolkit %s and " | "OpenSSL Project for use in the OpenSSL Toolkit %s and " | ||||
"cryptographic software written by Eric Young and UPnP " | "cryptographic software written by Eric Young and UPnP " | ||||
"software written by Thomas Bernard.") | "software written by Thomas Bernard.") | ||||
.translated, | .translated, | ||||
"<https://www.openssl.org>") + | "<https://www.openssl.org>") + | ||||
"\n"; | "\n"; | ||||
} | } | ||||
#if defined(HAVE_SYSTEM) | |||||
static void BlockNotifyCallback(bool initialSync, | static void BlockNotifyCallback(bool initialSync, | ||||
const CBlockIndex *pBlockIndex) { | const CBlockIndex *pBlockIndex) { | ||||
if (initialSync || !pBlockIndex) { | if (initialSync || !pBlockIndex) { | ||||
return; | return; | ||||
} | } | ||||
std::string strCmd = gArgs.GetArg("-blocknotify", ""); | std::string strCmd = gArgs.GetArg("-blocknotify", ""); | ||||
if (!strCmd.empty()) { | if (!strCmd.empty()) { | ||||
boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); | boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); | ||||
std::thread t(runCommand, strCmd); | std::thread t(runCommand, strCmd); | ||||
// thread runs free | // thread runs free | ||||
t.detach(); | t.detach(); | ||||
} | } | ||||
} | } | ||||
#endif | |||||
static bool fHaveGenesis = false; | static bool fHaveGenesis = false; | ||||
static Mutex g_genesis_wait_mutex; | static Mutex g_genesis_wait_mutex; | ||||
static std::condition_variable g_genesis_wait_cv; | static std::condition_variable g_genesis_wait_cv; | ||||
static void BlockNotifyGenesisWait(bool, const CBlockIndex *pBlockIndex) { | static void BlockNotifyGenesisWait(bool, const CBlockIndex *pBlockIndex) { | ||||
if (pBlockIndex != nullptr) { | if (pBlockIndex != nullptr) { | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,453 Lines • ▼ Show 20 Lines | #endif | ||||
// fHaveGenesis directly. | // fHaveGenesis directly. | ||||
// No locking, as this happens before any background thread is started. | // No locking, as this happens before any background thread is started. | ||||
if (::ChainActive().Tip() == nullptr) { | if (::ChainActive().Tip() == nullptr) { | ||||
uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait); | uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait); | ||||
} else { | } else { | ||||
fHaveGenesis = true; | fHaveGenesis = true; | ||||
} | } | ||||
#if defined(HAVE_SYSTEM) | |||||
if (gArgs.IsArgSet("-blocknotify")) { | if (gArgs.IsArgSet("-blocknotify")) { | ||||
uiInterface.NotifyBlockTip_connect(BlockNotifyCallback); | uiInterface.NotifyBlockTip_connect(BlockNotifyCallback); | ||||
} | } | ||||
#endif | |||||
std::vector<fs::path> vImportFiles; | std::vector<fs::path> vImportFiles; | ||||
for (const std::string &strFile : gArgs.GetArgs("-loadblock")) { | for (const std::string &strFile : gArgs.GetArgs("-loadblock")) { | ||||
vImportFiles.push_back(strFile); | vImportFiles.push_back(strFile); | ||||
} | } | ||||
threadGroup.create_thread( | threadGroup.create_thread( | ||||
std::bind(&ThreadImport, std::ref(config), vImportFiles)); | std::bind(&ThreadImport, std::ref(config), vImportFiles)); | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |