aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/blockchain.cpp
diff options
context:
space:
mode:
authorSjors Provoost <sjors@sprovoost.nl>2021-04-21 16:39:40 +0200
committerSjors Provoost <sjors@sprovoost.nl>2021-12-02 13:15:32 +0700
commitb884ababc29ce963826d8a4327ed6a5e629ff175 (patch)
tree55b49ff02eec85ec0f133a236c997ede8224c43e /src/rpc/blockchain.cpp
parentdf562d698a386166ef93d03326c0480ea9bc11fe (diff)
rpc: move Ensure* helpers to server_util.h
Diffstat (limited to 'src/rpc/blockchain.cpp')
-rw-r--r--src/rpc/blockchain.cpp50
1 files changed, 1 insertions, 49 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 55048f6811..6442d30feb 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -28,6 +28,7 @@
#include <policy/rbf.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
+#include <rpc/server_util.h>
#include <rpc/util.h>
#include <script/descriptor.h>
#include <streams.h>
@@ -37,7 +38,6 @@
#include <undo.h>
#include <util/strencodings.h>
#include <util/string.h>
-#include <util/system.h>
#include <util/translation.h>
#include <validation.h>
#include <validationinterface.h>
@@ -62,54 +62,6 @@ static Mutex cs_blockchange;
static std::condition_variable cond_blockchange;
static CUpdatedBlock latestblock GUARDED_BY(cs_blockchange);
-NodeContext& EnsureAnyNodeContext(const std::any& context)
-{
- auto node_context = util::AnyPtr<NodeContext>(context);
- if (!node_context) {
- throw JSONRPCError(RPC_INTERNAL_ERROR, "Node context not found");
- }
- return *node_context;
-}
-
-CTxMemPool& EnsureMemPool(const NodeContext& node)
-{
- if (!node.mempool) {
- throw JSONRPCError(RPC_CLIENT_MEMPOOL_DISABLED, "Mempool disabled or instance not found");
- }
- return *node.mempool;
-}
-
-CTxMemPool& EnsureAnyMemPool(const std::any& context)
-{
- return EnsureMemPool(EnsureAnyNodeContext(context));
-}
-
-ChainstateManager& EnsureChainman(const NodeContext& node)
-{
- if (!node.chainman) {
- throw JSONRPCError(RPC_INTERNAL_ERROR, "Node chainman not found");
- }
- return *node.chainman;
-}
-
-ChainstateManager& EnsureAnyChainman(const std::any& context)
-{
- return EnsureChainman(EnsureAnyNodeContext(context));
-}
-
-CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node)
-{
- if (!node.fee_estimator) {
- throw JSONRPCError(RPC_INTERNAL_ERROR, "Fee estimation disabled");
- }
- return *node.fee_estimator;
-}
-
-CBlockPolicyEstimator& EnsureAnyFeeEstimator(const std::any& context)
-{
- return EnsureFeeEstimator(EnsureAnyNodeContext(context));
-}
-
/* Calculate the difficulty for a given block index.
*/
double GetDifficulty(const CBlockIndex* blockindex)