mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
Make SetupServerArgs callable without NodeContext
bitcoin-gui code needs to call SetupServerArgs but will not have a NodeContext object if it is communicating with an external bitcoin-node process.
This commit is contained in:
parent
1704bbf226
commit
493fb47c57
7 changed files with 10 additions and 9 deletions
|
@ -112,8 +112,8 @@ static bool AppInit(NodeContext& node, int argc, char* argv[])
|
||||||
util::ThreadSetInternalName("init");
|
util::ThreadSetInternalName("init");
|
||||||
|
|
||||||
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
||||||
SetupServerArgs(node);
|
|
||||||
ArgsManager& args = *Assert(node.args);
|
ArgsManager& args = *Assert(node.args);
|
||||||
|
SetupServerArgs(args);
|
||||||
std::string error;
|
std::string error;
|
||||||
if (!args.ParseParameters(argc, argv, error)) {
|
if (!args.ParseParameters(argc, argv, error)) {
|
||||||
return InitError(Untranslated(strprintf("Error parsing command line arguments: %s\n", error)));
|
return InitError(Untranslated(strprintf("Error parsing command line arguments: %s\n", error)));
|
||||||
|
|
|
@ -347,12 +347,8 @@ static void OnRPCStopped()
|
||||||
LogPrint(BCLog::RPC, "RPC stopped.\n");
|
LogPrint(BCLog::RPC, "RPC stopped.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupServerArgs(NodeContext& node)
|
void SetupServerArgs(ArgsManager& argsman)
|
||||||
{
|
{
|
||||||
assert(!node.args);
|
|
||||||
node.args = &gArgs;
|
|
||||||
ArgsManager& argsman = *node.args;
|
|
||||||
|
|
||||||
SetupHelpOptions(argsman);
|
SetupHelpOptions(argsman);
|
||||||
argsman.AddArg("-help-debug", "Print help message with debugging options and exit", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); // server-only for now
|
argsman.AddArg("-help-debug", "Print help message with debugging options and exit", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); // server-only for now
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info
|
||||||
/**
|
/**
|
||||||
* Register all arguments with the ArgsManager
|
* Register all arguments with the ArgsManager
|
||||||
*/
|
*/
|
||||||
void SetupServerArgs(NodeContext& node);
|
void SetupServerArgs(ArgsManager& argsman);
|
||||||
|
|
||||||
/** Returns licensing information (for -version) */
|
/** Returns licensing information (for -version) */
|
||||||
std::string LicenseInfo();
|
std::string LicenseInfo();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <interfaces/init.h>
|
#include <interfaces/init.h>
|
||||||
#include <interfaces/ipc.h>
|
#include <interfaces/ipc.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
|
#include <util/system.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ public:
|
||||||
: m_node(node),
|
: m_node(node),
|
||||||
m_ipc(interfaces::MakeIpc(EXE_NAME, arg0, *this))
|
m_ipc(interfaces::MakeIpc(EXE_NAME, arg0, *this))
|
||||||
{
|
{
|
||||||
|
m_node.args = &gArgs;
|
||||||
m_node.init = this;
|
m_node.init = this;
|
||||||
}
|
}
|
||||||
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
|
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <interfaces/init.h>
|
#include <interfaces/init.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
|
#include <util/system.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ class BitcoindInit : public interfaces::Init
|
||||||
public:
|
public:
|
||||||
BitcoindInit(NodeContext& node) : m_node(node)
|
BitcoindInit(NodeContext& node) : m_node(node)
|
||||||
{
|
{
|
||||||
|
m_node.args = &gArgs;
|
||||||
m_node.init = this;
|
m_node.init = this;
|
||||||
}
|
}
|
||||||
NodeContext& m_node;
|
NodeContext& m_node;
|
||||||
|
|
|
@ -490,7 +490,7 @@ int GuiMain(int argc, char* argv[])
|
||||||
|
|
||||||
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
|
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
|
||||||
// Command-line options take precedence:
|
// Command-line options take precedence:
|
||||||
SetupServerArgs(node_context);
|
SetupServerArgs(gArgs);
|
||||||
SetupUIArgs(gArgs);
|
SetupUIArgs(gArgs);
|
||||||
std::string error;
|
std::string error;
|
||||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||||
|
|
|
@ -76,6 +76,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
|
||||||
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
|
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
|
||||||
m_args{}
|
m_args{}
|
||||||
{
|
{
|
||||||
|
m_node.args = &gArgs;
|
||||||
const std::vector<const char*> arguments = Cat(
|
const std::vector<const char*> arguments = Cat(
|
||||||
{
|
{
|
||||||
"dummy",
|
"dummy",
|
||||||
|
@ -94,7 +95,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
|
||||||
gArgs.ForceSetArg("-datadir", m_path_root.string());
|
gArgs.ForceSetArg("-datadir", m_path_root.string());
|
||||||
gArgs.ClearPathCache();
|
gArgs.ClearPathCache();
|
||||||
{
|
{
|
||||||
SetupServerArgs(m_node);
|
SetupServerArgs(*m_node.args);
|
||||||
std::string error;
|
std::string error;
|
||||||
const bool success{m_node.args->ParseParameters(arguments.size(), arguments.data(), error)};
|
const bool success{m_node.args->ParseParameters(arguments.size(), arguments.data(), error)};
|
||||||
assert(success);
|
assert(success);
|
||||||
|
|
Loading…
Add table
Reference in a new issue