aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/blockchain.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-01-04 15:39:53 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-01-04 15:40:35 +0100
commit300124dedfff411bcb9ef6572f35e3b581ec53a2 (patch)
treebbb01ba2aa9b6262cd8049c6495b756cd9b2b12c /src/rpc/blockchain.cpp
parent8319c4e906e6df5f2048e7c048942fde285a93a2 (diff)
parentfa5bb37611dea5d3e6715b0c84249e39ad1d2476 (diff)
downloadbitcoin-300124dedfff411bcb9ef6572f35e3b581ec53a2.tar.xz
Merge bitcoin/bitcoin#23936: rpc: Add and use EnsureArgsman helper
fa5bb37611dea5d3e6715b0c84249e39ad1d2476 rpc: Use EnsureAnyArgsman in rpc/blockchain (MarcoFalke) fa98b6f6449d33b315a73156c6de968f1757d53a rpc: Add EnsureArgsman helper (MarcoFalke) Pull request description: This refactor doesn't change anything for the rpc layer, but it helps a bit with removing gArgs (See #21005) ACKs for top commit: shaavan: Code Review ACK fa5bb37611dea5d3e6715b0c84249e39ad1d2476 Tree-SHA512: 18f9cc90830a168acb94452b541b6e97ba9a50a0f4834698a16994c3884c833dc606e36a5538a16352e5e5cc43d3ac77cb498f877f8f5bc5dd52fa84f8bf2056
Diffstat (limited to 'src/rpc/blockchain.cpp')
-rw-r--r--src/rpc/blockchain.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 269ef4fe48..20a5eea173 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1544,6 +1544,7 @@ RPCHelpMan getblockchaininfo()
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
+ const ArgsManager& args{EnsureAnyArgsman(request.context)};
ChainstateManager& chainman = EnsureAnyChainman(request.context);
LOCK(cs_main);
CChainState& active_chainstate = chainman.ActiveChainstate();
@@ -1574,7 +1575,7 @@ RPCHelpMan getblockchaininfo()
obj.pushKV("pruneheight", block->nHeight);
// if 0, execution bypasses the whole if block.
- bool automatic_pruning = (gArgs.GetIntArg("-prune", 0) != 1);
+ bool automatic_pruning{args.GetIntArg("-prune", 0) != 1};
obj.pushKV("automatic_pruning", automatic_pruning);
if (automatic_pruning) {
obj.pushKV("prune_target_size", nPruneTarget);
@@ -2270,10 +2271,9 @@ static RPCHelpMan savemempool()
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
+ const ArgsManager& args{EnsureAnyArgsman(request.context)};
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
- const NodeContext& node = EnsureAnyNodeContext(request.context);
-
if (!mempool.IsLoaded()) {
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
}
@@ -2283,7 +2283,7 @@ static RPCHelpMan savemempool()
}
UniValue ret(UniValue::VOBJ);
- ret.pushKV("filename", fs::path((node.args->GetDataDirNet() / "mempool.dat")).u8string());
+ ret.pushKV("filename", fs::path((args.GetDataDirNet() / "mempool.dat")).u8string());
return ret;
},
@@ -2628,10 +2628,11 @@ static RPCHelpMan dumptxoutset()
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
- const fs::path path = fsbridge::AbsPathJoin(gArgs.GetDataDirNet(), fs::u8path(request.params[0].get_str()));
+ const ArgsManager& args{EnsureAnyArgsman(request.context)};
+ const fs::path path = fsbridge::AbsPathJoin(args.GetDataDirNet(), fs::u8path(request.params[0].get_str()));
// Write to a temporary path and then move into `path` on completion
// to avoid confusion due to an interruption.
- const fs::path temppath = fsbridge::AbsPathJoin(gArgs.GetDataDirNet(), fs::u8path(request.params[0].get_str() + ".incomplete"));
+ const fs::path temppath = fsbridge::AbsPathJoin(args.GetDataDirNet(), fs::u8path(request.params[0].get_str() + ".incomplete"));
if (fs::exists(path)) {
throw JSONRPCError(