mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-21 05:00:10 +01:00
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.
This commit is contained in:
@@ -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<NodeContext>(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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user