mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
node: Add args alias for gArgs global
This commit is contained in:
parent
4bd6bc5cb4
commit
fad4fa7e2f
7 changed files with 14 additions and 6 deletions
|
@ -53,7 +53,7 @@ static bool AppInit(int argc, char* argv[])
|
|||
// Parameters
|
||||
//
|
||||
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
||||
SetupServerArgs();
|
||||
SetupServerArgs(node);
|
||||
std::string error;
|
||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||
return InitError(strprintf("Error parsing command line arguments: %s\n", error));
|
||||
|
|
|
@ -297,6 +297,7 @@ void Shutdown(NodeContext& node)
|
|||
GetMainSignals().UnregisterBackgroundSignalScheduler();
|
||||
globalVerifyHandle.reset();
|
||||
ECC_Stop();
|
||||
node.args = nullptr;
|
||||
if (node.mempool) node.mempool = nullptr;
|
||||
node.scheduler.reset();
|
||||
|
||||
|
@ -360,8 +361,11 @@ static void OnRPCStopped()
|
|||
LogPrint(BCLog::RPC, "RPC stopped.\n");
|
||||
}
|
||||
|
||||
void SetupServerArgs()
|
||||
void SetupServerArgs(NodeContext& node)
|
||||
{
|
||||
assert(!node.args);
|
||||
node.args = &gArgs;
|
||||
|
||||
SetupHelpOptions(gArgs);
|
||||
gArgs.AddArg("-help-debug", "Print help message with debugging options and exit", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); // server-only for now
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ bool AppInitLockDataDirectory();
|
|||
bool AppInitMain(NodeContext& node);
|
||||
|
||||
/**
|
||||
* Setup the arguments for gArgs
|
||||
* Register all arguments with the ArgsManager
|
||||
*/
|
||||
void SetupServerArgs();
|
||||
void SetupServerArgs(NodeContext& node);
|
||||
|
||||
/** Returns licensing information (for -version) */
|
||||
std::string LicenseInfo();
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
StopMapPort();
|
||||
}
|
||||
}
|
||||
void setupServerArgs() override { return SetupServerArgs(); }
|
||||
void setupServerArgs() override { return SetupServerArgs(m_context); }
|
||||
bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); }
|
||||
size_t getNodeCount(CConnman::NumConnections flags) override
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class ArgsManager;
|
||||
class BanMan;
|
||||
class CConnman;
|
||||
class CScheduler;
|
||||
|
@ -33,6 +34,7 @@ struct NodeContext {
|
|||
CTxMemPool* mempool{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
||||
std::unique_ptr<PeerLogicValidation> peer_logic;
|
||||
std::unique_ptr<BanMan> banman;
|
||||
ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
||||
std::unique_ptr<interfaces::Chain> chain;
|
||||
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
|
||||
std::unique_ptr<CScheduler> scheduler;
|
||||
|
|
|
@ -159,6 +159,7 @@ TestingSetup::~TestingSetup()
|
|||
g_rpc_node = nullptr;
|
||||
m_node.connman.reset();
|
||||
m_node.banman.reset();
|
||||
m_node.args = nullptr;
|
||||
m_node.mempool = nullptr;
|
||||
m_node.scheduler.reset();
|
||||
UnloadBlockIndex();
|
||||
|
|
|
@ -73,9 +73,11 @@ static constexpr CAmount CENT{1000000};
|
|||
*/
|
||||
struct BasicTestingSetup {
|
||||
ECCVerifyHandle globalVerifyHandle;
|
||||
NodeContext m_node;
|
||||
|
||||
explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
||||
~BasicTestingSetup();
|
||||
|
||||
private:
|
||||
const fs::path m_path_root;
|
||||
};
|
||||
|
@ -84,7 +86,6 @@ private:
|
|||
* Included are coins database, script check threads setup.
|
||||
*/
|
||||
struct TestingSetup : public BasicTestingSetup {
|
||||
NodeContext m_node;
|
||||
boost::thread_group threadGroup;
|
||||
|
||||
explicit TestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
||||
|
|
Loading…
Add table
Reference in a new issue