diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-01-02 10:24:24 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-01-02 10:29:11 +0100 |
commit | fa98b6f6449d33b315a73156c6de968f1757d53a (patch) | |
tree | b08d1af9e6c73b82774e4be011837ee36527e0e2 /src/rpc | |
parent | 8b5a4de904b414fb3a818732cd0a2c90b91bc275 (diff) |
rpc: Add EnsureArgsman helper
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/blockchain.h | 1 | ||||
-rw-r--r-- | src/rpc/server_util.cpp | 13 | ||||
-rw-r--r-- | src/rpc/server_util.h | 7 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index e487accb66..2176b5997e 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -21,7 +21,6 @@ class CBlock; class CBlockIndex; class CChainState; class CTxMemPool; -class ChainstateManager; class UniValue; struct NodeContext; diff --git a/src/rpc/server_util.cpp b/src/rpc/server_util.cpp index 3fc35222e1..2978051574 100644 --- a/src/rpc/server_util.cpp +++ b/src/rpc/server_util.cpp @@ -37,6 +37,19 @@ CTxMemPool& EnsureAnyMemPool(const std::any& context) return EnsureMemPool(EnsureAnyNodeContext(context)); } +ArgsManager& EnsureArgsman(const NodeContext& node) +{ + if (!node.args) { + throw JSONRPCError(RPC_INTERNAL_ERROR, "Node args not found"); + } + return *node.args; +} + +ArgsManager& EnsureAnyArgsman(const std::any& context) +{ + return EnsureArgsman(EnsureAnyNodeContext(context)); +} + ChainstateManager& EnsureChainman(const NodeContext& node) { if (!node.chainman) { diff --git a/src/rpc/server_util.h b/src/rpc/server_util.h index ad3c149c90..3b0df2d651 100644 --- a/src/rpc/server_util.h +++ b/src/rpc/server_util.h @@ -7,16 +7,19 @@ #include <any> +class ArgsManager; class CBlockPolicyEstimator; class CConnman; -class ChainstateManager; class CTxMemPool; -struct NodeContext; +class ChainstateManager; class PeerManager; +struct NodeContext; NodeContext& EnsureAnyNodeContext(const std::any& context); CTxMemPool& EnsureMemPool(const NodeContext& node); CTxMemPool& EnsureAnyMemPool(const std::any& context); +ArgsManager& EnsureArgsman(const NodeContext& node); +ArgsManager& EnsureAnyArgsman(const std::any& context); ChainstateManager& EnsureChainman(const NodeContext& node); ChainstateManager& EnsureAnyChainman(const std::any& context); CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node); |