rpc: Add EnsureArgsman helper

This commit is contained in:
MarcoFalke
2022-01-02 10:24:24 +01:00
parent 8b5a4de904
commit fa98b6f644
3 changed files with 18 additions and 3 deletions

View File

@ -21,7 +21,6 @@ class CBlock;
class CBlockIndex; class CBlockIndex;
class CChainState; class CChainState;
class CTxMemPool; class CTxMemPool;
class ChainstateManager;
class UniValue; class UniValue;
struct NodeContext; struct NodeContext;

View File

@ -37,6 +37,19 @@ CTxMemPool& EnsureAnyMemPool(const std::any& context)
return EnsureMemPool(EnsureAnyNodeContext(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) ChainstateManager& EnsureChainman(const NodeContext& node)
{ {
if (!node.chainman) { if (!node.chainman) {

View File

@ -7,16 +7,19 @@
#include <any> #include <any>
class ArgsManager;
class CBlockPolicyEstimator; class CBlockPolicyEstimator;
class CConnman; class CConnman;
class ChainstateManager;
class CTxMemPool; class CTxMemPool;
struct NodeContext; class ChainstateManager;
class PeerManager; class PeerManager;
struct NodeContext;
NodeContext& EnsureAnyNodeContext(const std::any& context); NodeContext& EnsureAnyNodeContext(const std::any& context);
CTxMemPool& EnsureMemPool(const NodeContext& node); CTxMemPool& EnsureMemPool(const NodeContext& node);
CTxMemPool& EnsureAnyMemPool(const std::any& context); CTxMemPool& EnsureAnyMemPool(const std::any& context);
ArgsManager& EnsureArgsman(const NodeContext& node);
ArgsManager& EnsureAnyArgsman(const std::any& context);
ChainstateManager& EnsureChainman(const NodeContext& node); ChainstateManager& EnsureChainman(const NodeContext& node);
ChainstateManager& EnsureAnyChainman(const std::any& context); ChainstateManager& EnsureAnyChainman(const std::any& context);
CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node); CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node);