mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-25 16:10:33 +02: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:
parent
306b1cd3ee
commit
1570c7ee98
@ -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));
|
||||
}
|
||||
|
@ -57,12 +57,16 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fInclud
|
||||
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex = true, int serialize_flags = 0, const CTxUndo* txundo = nullptr);
|
||||
|
||||
NodeContext& EnsureNodeContext(const std::any& context);
|
||||
NodeContext& EnsureAnyNodeContext(const std::any& context);
|
||||
CTxMemPool& EnsureMemPool(const NodeContext& node);
|
||||
CTxMemPool& EnsureMemPool(const std::any& context);
|
||||
CTxMemPool& EnsureAnyMemPool(const std::any& context);
|
||||
ChainstateManager& EnsureChainman(const NodeContext& node);
|
||||
ChainstateManager& EnsureChainman(const std::any& context);
|
||||
ChainstateManager& EnsureAnyChainman(const std::any& context);
|
||||
CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node);
|
||||
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& context);
|
||||
CBlockPolicyEstimator& EnsureAnyFeeEstimator(const std::any& context);
|
||||
|
||||
/**
|
||||
* Helper to create UTXO snapshots given a chainstate and a file handle.
|
||||
|
Loading…
x
Reference in New Issue
Block a user