mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-11 12:03:04 +02:00
init: Use InitError for all errors in bitcoind/qt
Also, remove unused <boost/thread.hpp> include (and others)
This commit is contained in:
@@ -11,15 +11,14 @@
|
||||
#include <clientversion.h>
|
||||
#include <compat.h>
|
||||
#include <fs.h>
|
||||
#include <interfaces/chain.h>
|
||||
#include <init.h>
|
||||
#include <interfaces/chain.h>
|
||||
#include <noui.h>
|
||||
#include <shutdown.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
#include <util/threadnames.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
@@ -70,8 +69,7 @@ static bool AppInit(int argc, char* argv[])
|
||||
SetupServerArgs();
|
||||
std::string error;
|
||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
return false;
|
||||
return InitError(strprintf("Error parsing command line arguments: %s\n", error));
|
||||
}
|
||||
|
||||
// Process help and version before taking care about datadir
|
||||
@@ -96,26 +94,22 @@ static bool AppInit(int argc, char* argv[])
|
||||
{
|
||||
if (!fs::is_directory(GetDataDir(false)))
|
||||
{
|
||||
tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
|
||||
return false;
|
||||
return InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")));
|
||||
}
|
||||
if (!gArgs.ReadConfigFiles(error, true)) {
|
||||
tfm::format(std::cerr, "Error reading configuration file: %s\n", error.c_str());
|
||||
return false;
|
||||
return InitError(strprintf("Error reading configuration file: %s\n", error));
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
try {
|
||||
SelectParams(gArgs.GetChainName());
|
||||
} catch (const std::exception& e) {
|
||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||
return false;
|
||||
return InitError(strprintf("%s\n", e.what()));
|
||||
}
|
||||
|
||||
// Error out when loose non-argument tokens are encountered on command line
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (!IsSwitchChar(argv[i][0])) {
|
||||
tfm::format(std::cerr, "Error: Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i]);
|
||||
return false;
|
||||
return InitError(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,19 +140,17 @@ static bool AppInit(int argc, char* argv[])
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
tfm::format(std::cout, "Bitcoin server starting\n");
|
||||
tfm::format(std::cout, PACKAGE_NAME "daemon starting\n");
|
||||
|
||||
// Daemonize
|
||||
if (daemon(1, 0)) { // don't chdir (1), do close FDs (0)
|
||||
tfm::format(std::cerr, "Error: daemon() failed: %s\n", strerror(errno));
|
||||
return false;
|
||||
return InitError(strprintf("daemon() failed: %s\n", strerror(errno)));
|
||||
}
|
||||
#if defined(MAC_OSX)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#else
|
||||
tfm::format(std::cerr, "Error: -daemon is not supported on this operating system\n");
|
||||
return false;
|
||||
return InitError("-daemon is not supported on this operating system\n");
|
||||
#endif // HAVE_DECL_DAEMON
|
||||
}
|
||||
// Lock data directory after daemonization
|
||||
|
Reference in New Issue
Block a user