Skip to content

Commit c2704ec

Browse files
committed
Merge #10607: scripted-diff: stop using the gArgs wrappers
fcbde90 remove unused gArgs wrappers (Marko Bencun) bb81e17 scripted-diff: stop using the gArgs wrappers (Marko Bencun) Tree-SHA512: 49190740dfc723d680a093b625bf4e4e010bc121741b035d790f787e73eedd74966e4ceaf56975050d06b5d7d6cd8f46f9deb5cc78569df1e9faf0d7e543ee21
2 parents 1227be3 + fcbde90 commit c2704ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+349
-395
lines changed

src/bitcoin-cli.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ static int AppInitRPC(int argc, char* argv[])
7979
//
8080
// Parameters
8181
//
82-
ParseParameters(argc, argv);
83-
if (argc<2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version")) {
82+
gArgs.ParseParameters(argc, argv);
83+
if (argc<2 || gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version")) {
8484
std::string strUsage = strprintf(_("%s RPC client version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n";
85-
if (!IsArgSet("-version")) {
85+
if (!gArgs.IsArgSet("-version")) {
8686
strUsage += "\n" + _("Usage:") + "\n" +
8787
" bitcoin-cli [options] <command> [params] " + strprintf(_("Send command to %s"), _(PACKAGE_NAME)) + "\n" +
8888
" bitcoin-cli [options] -named <command> [name=value] ... " + strprintf(_("Send command to %s (with named arguments)"), _(PACKAGE_NAME)) + "\n" +
@@ -100,11 +100,11 @@ static int AppInitRPC(int argc, char* argv[])
100100
return EXIT_SUCCESS;
101101
}
102102
if (!fs::is_directory(GetDataDir(false))) {
103-
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str());
103+
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
104104
return EXIT_FAILURE;
105105
}
106106
try {
107-
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME));
107+
gArgs.ReadConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
108108
} catch (const std::exception& e) {
109109
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
110110
return EXIT_FAILURE;
@@ -116,7 +116,7 @@ static int AppInitRPC(int argc, char* argv[])
116116
fprintf(stderr, "Error: %s\n", e.what());
117117
return EXIT_FAILURE;
118118
}
119-
if (GetBoolArg("-rpcssl", false))
119+
if (gArgs.GetBoolArg("-rpcssl", false))
120120
{
121121
fprintf(stderr, "Error: SSL mode for RPC (-rpcssl) is no longer supported.\n");
122122
return EXIT_FAILURE;
@@ -198,15 +198,15 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
198198
// 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6)
199199
// 3. default port for chain
200200
int port = BaseParams().RPCPort();
201-
SplitHostPort(GetArg("-rpcconnect", DEFAULT_RPCCONNECT), port, host);
202-
port = GetArg("-rpcport", port);
201+
SplitHostPort(gArgs.GetArg("-rpcconnect", DEFAULT_RPCCONNECT), port, host);
202+
port = gArgs.GetArg("-rpcport", port);
203203

204204
// Obtain event base
205205
raii_event_base base = obtain_event_base();
206206

207207
// Synchronously look up hostname
208208
raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port);
209-
evhttp_connection_set_timeout(evcon.get(), GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
209+
evhttp_connection_set_timeout(evcon.get(), gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
210210

211211
HTTPReply response;
212212
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
@@ -218,16 +218,16 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
218218

219219
// Get credentials
220220
std::string strRPCUserColonPass;
221-
if (GetArg("-rpcpassword", "") == "") {
221+
if (gArgs.GetArg("-rpcpassword", "") == "") {
222222
// Try fall back to cookie-based authentication if no password is provided
223223
if (!GetAuthCookie(&strRPCUserColonPass)) {
224224
throw std::runtime_error(strprintf(
225225
_("Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)"),
226-
GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
226+
GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
227227

228228
}
229229
} else {
230-
strRPCUserColonPass = GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", "");
230+
strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", "");
231231
}
232232

233233
struct evkeyvalq* output_headers = evhttp_request_get_output_headers(req.get());
@@ -244,7 +244,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
244244

245245
// check if we should use a special wallet endpoint
246246
std::string endpoint = "/";
247-
std::string walletName = GetArg("-rpcwallet", "");
247+
std::string walletName = gArgs.GetArg("-rpcwallet", "");
248248
if (!walletName.empty()) {
249249
char *encodedURI = evhttp_uriencode(walletName.c_str(), walletName.size(), false);
250250
if (encodedURI) {
@@ -294,7 +294,7 @@ int CommandLineRPC(int argc, char *argv[])
294294
argv++;
295295
}
296296
std::vector<std::string> args = std::vector<std::string>(&argv[1], &argv[argc]);
297-
if (GetBoolArg("-stdin", false)) {
297+
if (gArgs.GetBoolArg("-stdin", false)) {
298298
// Read one arg per line from stdin and append
299299
std::string line;
300300
while (std::getline(std::cin,line))
@@ -306,14 +306,14 @@ int CommandLineRPC(int argc, char *argv[])
306306
args.erase(args.begin()); // Remove trailing method name from arguments vector
307307

308308
UniValue params;
309-
if(GetBoolArg("-named", DEFAULT_NAMED)) {
309+
if(gArgs.GetBoolArg("-named", DEFAULT_NAMED)) {
310310
params = RPCConvertNamedValues(strMethod, args);
311311
} else {
312312
params = RPCConvertValues(strMethod, args);
313313
}
314314

315315
// Execute and handle connection failures with -rpcwait
316-
const bool fWait = GetBoolArg("-rpcwait", false);
316+
const bool fWait = gArgs.GetBoolArg("-rpcwait", false);
317317
do {
318318
try {
319319
const UniValue reply = CallRPC(strMethod, params);

src/bitcoin-tx.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int AppInitRawTx(int argc, char* argv[])
3939
//
4040
// Parameters
4141
//
42-
ParseParameters(argc, argv);
42+
gArgs.ParseParameters(argc, argv);
4343

4444
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
4545
try {
@@ -49,9 +49,9 @@ static int AppInitRawTx(int argc, char* argv[])
4949
return EXIT_FAILURE;
5050
}
5151

52-
fCreateBlank = GetBoolArg("-create", false);
52+
fCreateBlank = gArgs.GetBoolArg("-create", false);
5353

54-
if (argc<2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help"))
54+
if (argc<2 || gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help"))
5555
{
5656
// First part of help message is specific to this utility
5757
std::string strUsage = strprintf(_("%s bitcoin-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" +
@@ -737,9 +737,9 @@ static void OutputTxHex(const CTransaction& tx)
737737

738738
static void OutputTx(const CTransaction& tx)
739739
{
740-
if (GetBoolArg("-json", false))
740+
if (gArgs.GetBoolArg("-json", false))
741741
OutputTxJSON(tx);
742-
else if (GetBoolArg("-txid", false))
742+
else if (gArgs.GetBoolArg("-txid", false))
743743
OutputTxHash(tx);
744744
else
745745
OutputTxHex(tx);

src/bitcoind.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ bool AppInit(int argc, char* argv[])
7171
// Parameters
7272
//
7373
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
74-
ParseParameters(argc, argv);
74+
gArgs.ParseParameters(argc, argv);
7575

7676
// Process help and version before taking care about datadir
77-
if (IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version"))
77+
if (gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version"))
7878
{
7979
std::string strUsage = strprintf(_("%s Daemon"), _(PACKAGE_NAME)) + " " + _("version") + " " + FormatFullVersion() + "\n";
8080

81-
if (IsArgSet("-version"))
81+
if (gArgs.IsArgSet("-version"))
8282
{
8383
strUsage += FormatParagraph(LicenseInfo());
8484
}
@@ -98,12 +98,12 @@ bool AppInit(int argc, char* argv[])
9898
{
9999
if (!fs::is_directory(GetDataDir(false)))
100100
{
101-
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str());
101+
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
102102
return false;
103103
}
104104
try
105105
{
106-
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME));
106+
gArgs.ReadConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
107107
} catch (const std::exception& e) {
108108
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
109109
return false;
@@ -125,7 +125,7 @@ bool AppInit(int argc, char* argv[])
125125
}
126126

127127
// -server defaults to true for bitcoind but not for the GUI so do this here
128-
SoftSetBoolArg("-server", true);
128+
gArgs.SoftSetBoolArg("-server", true);
129129
// Set this early so that parameter interactions go to console
130130
InitLogging();
131131
InitParameterInteraction();
@@ -144,7 +144,7 @@ bool AppInit(int argc, char* argv[])
144144
// InitError will have been called with detailed error, which ends up on console
145145
exit(EXIT_FAILURE);
146146
}
147-
if (GetBoolArg("-daemon", false))
147+
if (gArgs.GetBoolArg("-daemon", false))
148148
{
149149
#if HAVE_DECL_DAEMON
150150
fprintf(stdout, "Bitcoin server starting\n");

src/chainparamsbase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void SelectBaseParams(const std::string& chain)
8989

9090
std::string ChainNameFromCommandLine()
9191
{
92-
bool fRegTest = GetBoolArg("-regtest", false);
93-
bool fTestNet = GetBoolArg("-testnet", false);
92+
bool fRegTest = gArgs.GetBoolArg("-regtest", false);
93+
bool fTestNet = gArgs.GetBoolArg("-testnet", false);
9494

9595
if (fTestNet && fRegTest)
9696
throw std::runtime_error("Invalid combination of -regtest and -testnet.");

src/dbwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bo
115115
dbwrapper_private::HandleError(status);
116116
LogPrintf("Opened LevelDB successfully\n");
117117

118-
if (GetBoolArg("-forcecompactdb", false)) {
118+
if (gArgs.GetBoolArg("-forcecompactdb", false)) {
119119
LogPrintf("Starting database compaction of %s\n", path.string());
120120
pdb->CompactRange(nullptr, nullptr);
121121
LogPrintf("Finished database compaction of %s\n", path.string());

src/httprpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
210210

211211
static bool InitRPCAuthentication()
212212
{
213-
if (GetArg("-rpcpassword", "") == "")
213+
if (gArgs.GetArg("-rpcpassword", "") == "")
214214
{
215215
LogPrintf("No rpcpassword set - using random cookie authentication\n");
216216
if (!GenerateAuthCookie(&strRPCUserColonPass)) {
@@ -221,7 +221,7 @@ static bool InitRPCAuthentication()
221221
}
222222
} else {
223223
LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.\n");
224-
strRPCUserColonPass = GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", "");
224+
strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", "");
225225
}
226226
return true;
227227
}

src/httpserver.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,14 @@ static bool ThreadHTTP(struct event_base* base, struct evhttp* http)
309309
/** Bind HTTP server to specified addresses */
310310
static bool HTTPBindAddresses(struct evhttp* http)
311311
{
312-
int defaultPort = GetArg("-rpcport", BaseParams().RPCPort());
312+
int defaultPort = gArgs.GetArg("-rpcport", BaseParams().RPCPort());
313313
std::vector<std::pair<std::string, uint16_t> > endpoints;
314314

315315
// Determine what addresses to bind to
316-
if (!IsArgSet("-rpcallowip")) { // Default to loopback if not allowing external IPs
316+
if (!gArgs.IsArgSet("-rpcallowip")) { // Default to loopback if not allowing external IPs
317317
endpoints.push_back(std::make_pair("::1", defaultPort));
318318
endpoints.push_back(std::make_pair("127.0.0.1", defaultPort));
319-
if (IsArgSet("-rpcbind")) {
319+
if (gArgs.IsArgSet("-rpcbind")) {
320320
LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
321321
}
322322
} else if (gArgs.IsArgSet("-rpcbind")) { // Specific bind address
@@ -369,7 +369,7 @@ bool InitHTTPServer()
369369
if (!InitHTTPAllowList())
370370
return false;
371371

372-
if (GetBoolArg("-rpcssl", false)) {
372+
if (gArgs.GetBoolArg("-rpcssl", false)) {
373373
uiInterface.ThreadSafeMessageBox(
374374
"SSL mode for RPC (-rpcssl) is no longer supported.",
375375
"", CClientUIInterface::MSG_ERROR);
@@ -401,7 +401,7 @@ bool InitHTTPServer()
401401
return false;
402402
}
403403

404-
evhttp_set_timeout(http, GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT));
404+
evhttp_set_timeout(http, gArgs.GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT));
405405
evhttp_set_max_headers_size(http, MAX_HEADERS_SIZE);
406406
evhttp_set_max_body_size(http, MAX_SIZE);
407407
evhttp_set_gencb(http, http_request_cb, nullptr);
@@ -412,7 +412,7 @@ bool InitHTTPServer()
412412
}
413413

414414
LogPrint(BCLog::HTTP, "Initialized HTTP server\n");
415-
int workQueueDepth = std::max((long)GetArg("-rpcworkqueue", DEFAULT_HTTP_WORKQUEUE), 1L);
415+
int workQueueDepth = std::max((long)gArgs.GetArg("-rpcworkqueue", DEFAULT_HTTP_WORKQUEUE), 1L);
416416
LogPrintf("HTTP: creating work queue of depth %d\n", workQueueDepth);
417417

418418
workQueue = new WorkQueue<HTTPClosure>(workQueueDepth);
@@ -442,7 +442,7 @@ std::future<bool> threadResult;
442442
bool StartHTTPServer()
443443
{
444444
LogPrint(BCLog::HTTP, "Starting HTTP server\n");
445-
int rpcThreads = std::max((long)GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L);
445+
int rpcThreads = std::max((long)gArgs.GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L);
446446
LogPrintf("HTTP: starting %d worker threads\n", rpcThreads);
447447
std::packaged_task<bool(event_base*, evhttp*)> task(ThreadHTTP);
448448
threadResult = task.get_future();

0 commit comments

Comments
 (0)