Skip to content

Commit fa98b6f

Browse files
author
MarcoFalke
committed
rpc: Add EnsureArgsman helper
1 parent 8b5a4de commit fa98b6f

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/rpc/blockchain.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class CBlock;
2121
class CBlockIndex;
2222
class CChainState;
2323
class CTxMemPool;
24-
class ChainstateManager;
2524
class UniValue;
2625
struct NodeContext;
2726

src/rpc/server_util.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ CTxMemPool& EnsureAnyMemPool(const std::any& context)
3737
return EnsureMemPool(EnsureAnyNodeContext(context));
3838
}
3939

40+
ArgsManager& EnsureArgsman(const NodeContext& node)
41+
{
42+
if (!node.args) {
43+
throw JSONRPCError(RPC_INTERNAL_ERROR, "Node args not found");
44+
}
45+
return *node.args;
46+
}
47+
48+
ArgsManager& EnsureAnyArgsman(const std::any& context)
49+
{
50+
return EnsureArgsman(EnsureAnyNodeContext(context));
51+
}
52+
4053
ChainstateManager& EnsureChainman(const NodeContext& node)
4154
{
4255
if (!node.chainman) {

src/rpc/server_util.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77

88
#include <any>
99

10+
class ArgsManager;
1011
class CBlockPolicyEstimator;
1112
class CConnman;
12-
class ChainstateManager;
1313
class CTxMemPool;
14-
struct NodeContext;
14+
class ChainstateManager;
1515
class PeerManager;
16+
struct NodeContext;
1617

1718
NodeContext& EnsureAnyNodeContext(const std::any& context);
1819
CTxMemPool& EnsureMemPool(const NodeContext& node);
1920
CTxMemPool& EnsureAnyMemPool(const std::any& context);
21+
ArgsManager& EnsureArgsman(const NodeContext& node);
22+
ArgsManager& EnsureAnyArgsman(const std::any& context);
2023
ChainstateManager& EnsureChainman(const NodeContext& node);
2124
ChainstateManager& EnsureAnyChainman(const std::any& context);
2225
CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node);

0 commit comments

Comments
 (0)