@@ -86,14 +86,14 @@ class NodeImpl : public Node
8686{
8787public:
8888 explicit NodeImpl (NodeContext& context) { setContext (&context); }
89- void initLogging () override { InitLogging (* Assert (m_context-> args )); }
90- void initParameterInteraction () override { InitParameterInteraction (* Assert (m_context-> args )); }
89+ void initLogging () override { InitLogging (args ( )); }
90+ void initParameterInteraction () override { InitParameterInteraction (args ( )); }
9191 bilingual_str getWarnings () override { return GetWarnings (true ); }
9292 uint32_t getLogCategories () override { return LogInstance ().GetCategoryMask (); }
9393 bool baseInitialize () override
9494 {
95- if (!AppInitBasicSetup (gArgs )) return false ;
96- if (!AppInitParameterInteraction (gArgs , /* use_syscall_sandbox=*/ false )) return false ;
95+ if (!AppInitBasicSetup (args () )) return false ;
96+ if (!AppInitParameterInteraction (args () , /* use_syscall_sandbox=*/ false )) return false ;
9797
9898 m_context->kernel = std::make_unique<kernel::Context>();
9999 if (!AppInitSanityChecks (*m_context->kernel )) return false ;
@@ -116,7 +116,7 @@ class NodeImpl : public Node
116116 {
117117 StartShutdown ();
118118 // Stop RPC for clean shutdown if any of waitfor* commands is executed.
119- if (gArgs .GetBoolArg (" -server" , false )) {
119+ if (args () .GetBoolArg (" -server" , false )) {
120120 InterruptRPC ();
121121 StopRPC ();
122122 }
@@ -125,28 +125,28 @@ class NodeImpl : public Node
125125 bool isSettingIgnored (const std::string& name) override
126126 {
127127 bool ignored = false ;
128- gArgs .LockSettings ([&](util::Settings& settings) {
128+ args () .LockSettings ([&](util::Settings& settings) {
129129 if (auto * options = util::FindKey (settings.command_line_options , name)) {
130130 ignored = !options->empty ();
131131 }
132132 });
133133 return ignored;
134134 }
135- util::SettingsValue getPersistentSetting (const std::string& name) override { return gArgs .GetPersistentSetting (name); }
135+ util::SettingsValue getPersistentSetting (const std::string& name) override { return args () .GetPersistentSetting (name); }
136136 void updateRwSetting (const std::string& name, const util::SettingsValue& value) override
137137 {
138- gArgs .LockSettings ([&](util::Settings& settings) {
138+ args () .LockSettings ([&](util::Settings& settings) {
139139 if (value.isNull ()) {
140140 settings.rw_settings .erase (name);
141141 } else {
142142 settings.rw_settings [name] = value;
143143 }
144144 });
145- gArgs .WriteSettingsFile ();
145+ args () .WriteSettingsFile ();
146146 }
147147 void forceSetting (const std::string& name, const util::SettingsValue& value) override
148148 {
149- gArgs .LockSettings ([&](util::Settings& settings) {
149+ args () .LockSettings ([&](util::Settings& settings) {
150150 if (value.isNull ()) {
151151 settings.forced_settings .erase (name);
152152 } else {
@@ -156,11 +156,11 @@ class NodeImpl : public Node
156156 }
157157 void resetSettings () override
158158 {
159- gArgs .WriteSettingsFile (/* errors=*/ nullptr , /* backup=*/ true );
160- gArgs .LockSettings ([&](util::Settings& settings) {
159+ args () .WriteSettingsFile (/* errors=*/ nullptr , /* backup=*/ true );
160+ args () .LockSettings ([&](util::Settings& settings) {
161161 settings.rw_settings .clear ();
162162 });
163- gArgs .WriteSettingsFile ();
163+ args () .WriteSettingsFile ();
164164 }
165165 void mapPort (bool use_upnp, bool use_natpmp) override { StartMapPort (use_upnp, use_natpmp); }
166166 bool getProxy (Network net, Proxy& proxy_info) override { return GetProxy (net, proxy_info); }
@@ -237,7 +237,7 @@ class NodeImpl : public Node
237237 {
238238#ifdef ENABLE_EXTERNAL_SIGNER
239239 std::vector<ExternalSigner> signers = {};
240- const std::string command = gArgs .GetArg (" -signer" , " " );
240+ const std::string command = args () .GetArg (" -signer" , " " );
241241 if (command == " " ) return {};
242242 ExternalSigner::Enumerate (command, signers, Params ().NetworkIDString ());
243243 std::vector<std::unique_ptr<interfaces::ExternalSigner>> result;
@@ -388,6 +388,7 @@ class NodeImpl : public Node
388388 {
389389 m_context = context;
390390 }
391+ ArgsManager& args () { return *Assert (Assert (m_context)->args ); }
391392 ChainstateManager& chainman () { return *Assert (m_context->chainman ); }
392393 NodeContext* m_context{nullptr };
393394};
@@ -744,16 +745,16 @@ class ChainImpl : public Chain
744745 int rpcSerializationFlags () override { return RPCSerializationFlags (); }
745746 util::SettingsValue getSetting (const std::string& name) override
746747 {
747- return gArgs .GetSetting (name);
748+ return args () .GetSetting (name);
748749 }
749750 std::vector<util::SettingsValue> getSettingsList (const std::string& name) override
750751 {
751- return gArgs .GetSettingsList (name);
752+ return args () .GetSettingsList (name);
752753 }
753754 util::SettingsValue getRwSetting (const std::string& name) override
754755 {
755756 util::SettingsValue result;
756- gArgs .LockSettings ([&](const util::Settings& settings) {
757+ args () .LockSettings ([&](const util::Settings& settings) {
757758 if (const util::SettingsValue* value = util::FindKey (settings.rw_settings , name)) {
758759 result = *value;
759760 }
@@ -762,14 +763,14 @@ class ChainImpl : public Chain
762763 }
763764 bool updateRwSetting (const std::string& name, const util::SettingsValue& value, bool write) override
764765 {
765- gArgs .LockSettings ([&](util::Settings& settings) {
766+ args () .LockSettings ([&](util::Settings& settings) {
766767 if (value.isNull ()) {
767768 settings.rw_settings .erase (name);
768769 } else {
769770 settings.rw_settings [name] = value;
770771 }
771772 });
772- return !write || gArgs .WriteSettingsFile ();
773+ return !write || args () .WriteSettingsFile ();
773774 }
774775 void requestMempoolTransactions (Notifications& notifications) override
775776 {
@@ -785,6 +786,7 @@ class ChainImpl : public Chain
785786 }
786787
787788 NodeContext* context () override { return &m_node; }
789+ ArgsManager& args () { return *Assert (m_node.args ); }
788790 ChainstateManager& chainman () { return *Assert (m_node.chainman ); }
789791 NodeContext& m_node;
790792};
0 commit comments