Skip to content

Commit fa5bb37

Browse files
author
MarcoFalke
committed
rpc: Use EnsureAnyArgsman in rpc/blockchain
1 parent fa98b6f commit fa5bb37

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/rpc/blockchain.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,7 @@ RPCHelpMan getblockchaininfo()
15121512
},
15131513
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
15141514
{
1515+
const ArgsManager& args{EnsureAnyArgsman(request.context)};
15151516
ChainstateManager& chainman = EnsureAnyChainman(request.context);
15161517
LOCK(cs_main);
15171518
CChainState& active_chainstate = chainman.ActiveChainstate();
@@ -1542,7 +1543,7 @@ RPCHelpMan getblockchaininfo()
15421543
obj.pushKV("pruneheight", block->nHeight);
15431544

15441545
// if 0, execution bypasses the whole if block.
1545-
bool automatic_pruning = (gArgs.GetIntArg("-prune", 0) != 1);
1546+
bool automatic_pruning{args.GetIntArg("-prune", 0) != 1};
15461547
obj.pushKV("automatic_pruning", automatic_pruning);
15471548
if (automatic_pruning) {
15481549
obj.pushKV("prune_target_size", nPruneTarget);
@@ -2238,10 +2239,9 @@ static RPCHelpMan savemempool()
22382239
},
22392240
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
22402241
{
2242+
const ArgsManager& args{EnsureAnyArgsman(request.context)};
22412243
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
22422244

2243-
const NodeContext& node = EnsureAnyNodeContext(request.context);
2244-
22452245
if (!mempool.IsLoaded()) {
22462246
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
22472247
}
@@ -2251,7 +2251,7 @@ static RPCHelpMan savemempool()
22512251
}
22522252

22532253
UniValue ret(UniValue::VOBJ);
2254-
ret.pushKV("filename", fs::path((node.args->GetDataDirNet() / "mempool.dat")).u8string());
2254+
ret.pushKV("filename", fs::path((args.GetDataDirNet() / "mempool.dat")).u8string());
22552255

22562256
return ret;
22572257
},
@@ -2600,10 +2600,11 @@ static RPCHelpMan dumptxoutset()
26002600
},
26012601
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
26022602
{
2603-
const fs::path path = fsbridge::AbsPathJoin(gArgs.GetDataDirNet(), fs::u8path(request.params[0].get_str()));
2603+
const ArgsManager& args{EnsureAnyArgsman(request.context)};
2604+
const fs::path path = fsbridge::AbsPathJoin(args.GetDataDirNet(), fs::u8path(request.params[0].get_str()));
26042605
// Write to a temporary path and then move into `path` on completion
26052606
// to avoid confusion due to an interruption.
2606-
const fs::path temppath = fsbridge::AbsPathJoin(gArgs.GetDataDirNet(), fs::u8path(request.params[0].get_str() + ".incomplete"));
2607+
const fs::path temppath = fsbridge::AbsPathJoin(args.GetDataDirNet(), fs::u8path(request.params[0].get_str() + ".incomplete"));
26072608

26082609
if (fs::exists(path)) {
26092610
throw JSONRPCError(

0 commit comments

Comments
 (0)