Skip to content

Commit 1570c7e

Browse files
committed
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.
1 parent 306b1cd commit 1570c7e

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/rpc/blockchain.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ static Mutex cs_blockchange;
5555
static std::condition_variable cond_blockchange;
5656
static CUpdatedBlock latestblock GUARDED_BY(cs_blockchange);
5757

58-
NodeContext& EnsureNodeContext(const std::any& context)
58+
NodeContext& EnsureNodeContext(const std::any& ctx) {
59+
return EnsureAnyNodeContext(ctx);
60+
}
61+
62+
NodeContext& EnsureAnyNodeContext(const std::any& context)
5963
{
6064
auto node_context = util::AnyPtr<NodeContext>(context);
6165
if (!node_context) {
@@ -64,6 +68,10 @@ NodeContext& EnsureNodeContext(const std::any& context)
6468
return *node_context;
6569
}
6670

71+
CTxMemPool& EnsureMemPool(const std::any& ctx) {
72+
return EnsureAnyMemPool(ctx);
73+
}
74+
6775
CTxMemPool& EnsureMemPool(const NodeContext& node)
6876
{
6977
if (!node.mempool) {
@@ -72,11 +80,15 @@ CTxMemPool& EnsureMemPool(const NodeContext& node)
7280
return *node.mempool;
7381
}
7482

75-
CTxMemPool& EnsureMemPool(const std::any& context)
83+
CTxMemPool& EnsureAnyMemPool(const std::any& context)
7684
{
7785
return EnsureMemPool(EnsureNodeContext(context));
7886
}
7987

88+
ChainstateManager& EnsureChainman(const std::any& ctx) {
89+
return EnsureAnyChainman(ctx);
90+
}
91+
8092
ChainstateManager& EnsureChainman(const NodeContext& node)
8193
{
8294
if (!node.chainman) {
@@ -86,11 +98,15 @@ ChainstateManager& EnsureChainman(const NodeContext& node)
8698
return *node.chainman;
8799
}
88100

89-
ChainstateManager& EnsureChainman(const std::any& context)
101+
ChainstateManager& EnsureAnyChainman(const std::any& context)
90102
{
91103
return EnsureChainman(EnsureNodeContext(context));
92104
}
93105

106+
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& ctx) {
107+
return EnsureAnyFeeEstimator(ctx);
108+
}
109+
94110
CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node)
95111
{
96112
if (!node.fee_estimator) {
@@ -99,7 +115,7 @@ CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node)
99115
return *node.fee_estimator;
100116
}
101117

102-
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& context)
118+
CBlockPolicyEstimator& EnsureAnyFeeEstimator(const std::any& context)
103119
{
104120
return EnsureFeeEstimator(EnsureNodeContext(context));
105121
}

src/rpc/blockchain.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,16 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fInclud
5757
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex = true, int serialize_flags = 0, const CTxUndo* txundo = nullptr);
5858

5959
NodeContext& EnsureNodeContext(const std::any& context);
60+
NodeContext& EnsureAnyNodeContext(const std::any& context);
6061
CTxMemPool& EnsureMemPool(const NodeContext& node);
6162
CTxMemPool& EnsureMemPool(const std::any& context);
63+
CTxMemPool& EnsureAnyMemPool(const std::any& context);
6264
ChainstateManager& EnsureChainman(const NodeContext& node);
6365
ChainstateManager& EnsureChainman(const std::any& context);
66+
ChainstateManager& EnsureAnyChainman(const std::any& context);
6467
CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node);
6568
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& context);
69+
CBlockPolicyEstimator& EnsureAnyFeeEstimator(const std::any& context);
6670

6771
/**
6872
* Helper to create UTXO snapshots given a chainstate and a file handle.

0 commit comments

Comments
 (0)