mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
init: add exe name to bitcoind, bitcoin-node -version output to be able to distinguish these in tests
Github-Pull: #33229
Rebased-From: 0972f55040
This commit is contained in:
@@ -132,11 +132,16 @@ static bool ParseArgs(NodeContext& node, int argc, char* argv[])
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ProcessInitCommands(ArgsManager& args)
|
||||
static bool ProcessInitCommands(interfaces::Init& init, ArgsManager& args)
|
||||
{
|
||||
// Process help and version before taking care about datadir
|
||||
if (HelpRequested(args) || args.GetBoolArg("-version", false)) {
|
||||
std::string strUsage = CLIENT_NAME " daemon version " + FormatFullVersion() + "\n";
|
||||
std::string strUsage = CLIENT_NAME " daemon version " + FormatFullVersion();
|
||||
if (const char* exe_name{init.exeName()}) {
|
||||
strUsage += " ";
|
||||
strUsage += exe_name;
|
||||
}
|
||||
strUsage += "\n";
|
||||
|
||||
if (args.GetBoolArg("-version", false)) {
|
||||
strUsage += FormatParagraph(LicenseInfo());
|
||||
@@ -277,7 +282,7 @@ MAIN_FUNCTION
|
||||
ArgsManager& args = *Assert(node.args);
|
||||
if (!ParseArgs(node, argc, argv)) return EXIT_FAILURE;
|
||||
// Process early info return commands such as -help or -version
|
||||
if (ProcessInitCommands(args)) return EXIT_SUCCESS;
|
||||
if (ProcessInitCommands(*init, args)) return EXIT_SUCCESS;
|
||||
|
||||
// Start application
|
||||
if (!AppInit(node) || !Assert(node.shutdown_signal)->wait()) {
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
// bitcoin-node accepts the option, and bitcoin-gui accepts all bitcoin-node
|
||||
// options and will start the node with those options.
|
||||
bool canListenIpc() override { return true; }
|
||||
const char* exeName() override { return EXE_NAME; }
|
||||
node::NodeContext m_node;
|
||||
std::unique_ptr<interfaces::Ipc> m_ipc;
|
||||
};
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
|
||||
interfaces::Ipc* ipc() override { return m_ipc.get(); }
|
||||
bool canListenIpc() override { return true; }
|
||||
const char* exeName() override { return EXE_NAME; }
|
||||
node::NodeContext& m_node;
|
||||
std::unique_ptr<interfaces::Ipc> m_ipc;
|
||||
};
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
namespace init {
|
||||
namespace {
|
||||
const char* EXE_NAME = "bitcoin-qt";
|
||||
|
||||
class BitcoinQtInit : public interfaces::Init
|
||||
{
|
||||
public:
|
||||
@@ -32,6 +34,7 @@ public:
|
||||
return MakeWalletLoader(chain, *Assert(m_node.args));
|
||||
}
|
||||
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
|
||||
const char* exeName() override { return EXE_NAME; }
|
||||
node::NodeContext m_node;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -18,6 +18,8 @@ using node::NodeContext;
|
||||
|
||||
namespace init {
|
||||
namespace {
|
||||
const char* EXE_NAME = "bitcoind";
|
||||
|
||||
class BitcoindInit : public interfaces::Init
|
||||
{
|
||||
public:
|
||||
@@ -34,6 +36,7 @@ public:
|
||||
return MakeWalletLoader(chain, *Assert(m_node.args));
|
||||
}
|
||||
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
|
||||
const char* exeName() override { return EXE_NAME; }
|
||||
NodeContext& m_node;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
virtual std::unique_ptr<Echo> makeEcho() { return nullptr; }
|
||||
virtual Ipc* ipc() { return nullptr; }
|
||||
virtual bool canListenIpc() { return false; }
|
||||
virtual const char* exeName() { return nullptr; }
|
||||
};
|
||||
|
||||
//! Return implementation of Init interface for the node process. If the argv
|
||||
|
||||
Reference in New Issue
Block a user