From 1570c7ee98612366df031bebef9e0468fb57b8a2 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Wed, 14 Apr 2021 10:16:34 -0400 Subject: rpc: Add renamed EnsureAny*() functions - The original Ensure*(const std::any& context) functions are kept and the parameter renamed to ctx so that the scripted-diff in the subsequent commit will work as expected - The renaming avoids overloading mistakes arising out of the untyped std::any argument. --- src/rpc/blockchain.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/rpc/blockchain.cpp') diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index cc7a29ffdb..074f3e3924 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -55,7 +55,11 @@ static Mutex cs_blockchange; static std::condition_variable cond_blockchange; static CUpdatedBlock latestblock GUARDED_BY(cs_blockchange); -NodeContext& EnsureNodeContext(const std::any& context) +NodeContext& EnsureNodeContext(const std::any& ctx) { + return EnsureAnyNodeContext(ctx); +} + +NodeContext& EnsureAnyNodeContext(const std::any& context) { auto node_context = util::AnyPtr(context); if (!node_context) { @@ -64,6 +68,10 @@ NodeContext& EnsureNodeContext(const std::any& context) return *node_context; } +CTxMemPool& EnsureMemPool(const std::any& ctx) { + return EnsureAnyMemPool(ctx); +} + CTxMemPool& EnsureMemPool(const NodeContext& node) { if (!node.mempool) { @@ -72,11 +80,15 @@ CTxMemPool& EnsureMemPool(const NodeContext& node) return *node.mempool; } -CTxMemPool& EnsureMemPool(const std::any& context) +CTxMemPool& EnsureAnyMemPool(const std::any& context) { return EnsureMemPool(EnsureNodeContext(context)); } +ChainstateManager& EnsureChainman(const std::any& ctx) { + return EnsureAnyChainman(ctx); +} + ChainstateManager& EnsureChainman(const NodeContext& node) { if (!node.chainman) { @@ -86,11 +98,15 @@ ChainstateManager& EnsureChainman(const NodeContext& node) return *node.chainman; } -ChainstateManager& EnsureChainman(const std::any& context) +ChainstateManager& EnsureAnyChainman(const std::any& context) { return EnsureChainman(EnsureNodeContext(context)); } +CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& ctx) { + return EnsureAnyFeeEstimator(ctx); +} + CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node) { if (!node.fee_estimator) { @@ -99,7 +115,7 @@ CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node) return *node.fee_estimator; } -CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& context) +CBlockPolicyEstimator& EnsureAnyFeeEstimator(const std::any& context) { return EnsureFeeEstimator(EnsureNodeContext(context)); } -- cgit v1.2.3