0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

rpc: Add EnsureArgsman helper

This commit is contained in:
MarcoFalke 2022-01-02 10:24:24 +01:00
parent 8b5a4de904
commit fa98b6f644
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
3 changed files with 18 additions and 3 deletions

View file

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

View file

@ -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) {

View file

@ -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);