mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-26 17:02:00 +02:00
rpc: Add alt Ensure* functions acepting NodeContext
This commit is contained in:
parent
d7824acdb9
commit
306b1cd3ee
@ -64,18 +64,21 @@ NodeContext& EnsureNodeContext(const std::any& context)
|
|||||||
return *node_context;
|
return *node_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxMemPool& EnsureMemPool(const std::any& context)
|
CTxMemPool& EnsureMemPool(const NodeContext& node)
|
||||||
{
|
{
|
||||||
const NodeContext& node = EnsureNodeContext(context);
|
|
||||||
if (!node.mempool) {
|
if (!node.mempool) {
|
||||||
throw JSONRPCError(RPC_CLIENT_MEMPOOL_DISABLED, "Mempool disabled or instance not found");
|
throw JSONRPCError(RPC_CLIENT_MEMPOOL_DISABLED, "Mempool disabled or instance not found");
|
||||||
}
|
}
|
||||||
return *node.mempool;
|
return *node.mempool;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChainstateManager& EnsureChainman(const std::any& context)
|
CTxMemPool& EnsureMemPool(const std::any& context)
|
||||||
|
{
|
||||||
|
return EnsureMemPool(EnsureNodeContext(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
ChainstateManager& EnsureChainman(const NodeContext& node)
|
||||||
{
|
{
|
||||||
const NodeContext& node = EnsureNodeContext(context);
|
|
||||||
if (!node.chainman) {
|
if (!node.chainman) {
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Node chainman not found");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Node chainman not found");
|
||||||
}
|
}
|
||||||
@ -83,15 +86,24 @@ ChainstateManager& EnsureChainman(const std::any& context)
|
|||||||
return *node.chainman;
|
return *node.chainman;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& context)
|
ChainstateManager& EnsureChainman(const std::any& context)
|
||||||
|
{
|
||||||
|
return EnsureChainman(EnsureNodeContext(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node)
|
||||||
{
|
{
|
||||||
NodeContext& node = EnsureNodeContext(context);
|
|
||||||
if (!node.fee_estimator) {
|
if (!node.fee_estimator) {
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Fee estimation disabled");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Fee estimation disabled");
|
||||||
}
|
}
|
||||||
return *node.fee_estimator;
|
return *node.fee_estimator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& context)
|
||||||
|
{
|
||||||
|
return EnsureFeeEstimator(EnsureNodeContext(context));
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate the difficulty for a given block index.
|
/* Calculate the difficulty for a given block index.
|
||||||
*/
|
*/
|
||||||
double GetDifficulty(const CBlockIndex* blockindex)
|
double GetDifficulty(const CBlockIndex* blockindex)
|
||||||
|
@ -57,8 +57,11 @@ 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);
|
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& EnsureNodeContext(const std::any& context);
|
||||||
|
CTxMemPool& EnsureMemPool(const NodeContext& node);
|
||||||
CTxMemPool& EnsureMemPool(const std::any& context);
|
CTxMemPool& EnsureMemPool(const std::any& context);
|
||||||
|
ChainstateManager& EnsureChainman(const NodeContext& node);
|
||||||
ChainstateManager& EnsureChainman(const std::any& context);
|
ChainstateManager& EnsureChainman(const std::any& context);
|
||||||
|
CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node);
|
||||||
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& context);
|
CBlockPolicyEstimator& EnsureFeeEstimator(const std::any& context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user