@@ -82,7 +82,7 @@ CTxMemPool& EnsureMemPool(const NodeContext& node)
82
82
83
83
CTxMemPool& EnsureAnyMemPool (const std::any& context)
84
84
{
85
- return EnsureMemPool (EnsureNodeContext (context));
85
+ return EnsureMemPool (EnsureAnyNodeContext (context));
86
86
}
87
87
88
88
ChainstateManager& EnsureChainman (const std::any& ctx) {
@@ -100,7 +100,7 @@ ChainstateManager& EnsureChainman(const NodeContext& node)
100
100
101
101
ChainstateManager& EnsureAnyChainman (const std::any& context)
102
102
{
103
- return EnsureChainman (EnsureNodeContext (context));
103
+ return EnsureChainman (EnsureAnyNodeContext (context));
104
104
}
105
105
106
106
CBlockPolicyEstimator& EnsureFeeEstimator (const std::any& ctx) {
@@ -117,7 +117,7 @@ CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node)
117
117
118
118
CBlockPolicyEstimator& EnsureAnyFeeEstimator (const std::any& context)
119
119
{
120
- return EnsureFeeEstimator (EnsureNodeContext (context));
120
+ return EnsureFeeEstimator (EnsureAnyNodeContext (context));
121
121
}
122
122
123
123
/* Calculate the difficulty for a given block index.
@@ -227,7 +227,7 @@ static RPCHelpMan getblockcount()
227
227
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
228
228
{
229
229
LOCK (cs_main);
230
- return EnsureChainman (request.context ).ActiveChain ().Height ();
230
+ return EnsureAnyChainman (request.context ).ActiveChain ().Height ();
231
231
},
232
232
};
233
233
}
@@ -246,7 +246,7 @@ static RPCHelpMan getbestblockhash()
246
246
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
247
247
{
248
248
LOCK (cs_main);
249
- return EnsureChainman (request.context ).ActiveChain ().Tip ()->GetBlockHash ().GetHex ();
249
+ return EnsureAnyChainman (request.context ).ActiveChain ().Tip ()->GetBlockHash ().GetHex ();
250
250
},
251
251
};
252
252
}
@@ -427,7 +427,7 @@ static RPCHelpMan getdifficulty()
427
427
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
428
428
{
429
429
LOCK (cs_main);
430
- return GetDifficulty (EnsureChainman (request.context ).ActiveChain ().Tip ());
430
+ return GetDifficulty (EnsureAnyChainman (request.context ).ActiveChain ().Tip ());
431
431
},
432
432
};
433
433
}
@@ -609,7 +609,7 @@ static RPCHelpMan getrawmempool()
609
609
include_mempool_sequence = request.params [1 ].get_bool ();
610
610
}
611
611
612
- return MempoolToJSON (EnsureMemPool (request.context ), fVerbose , include_mempool_sequence);
612
+ return MempoolToJSON (EnsureAnyMemPool (request.context ), fVerbose , include_mempool_sequence);
613
613
},
614
614
};
615
615
}
@@ -644,7 +644,7 @@ static RPCHelpMan getmempoolancestors()
644
644
645
645
uint256 hash = ParseHashV (request.params [0 ], " parameter 1" );
646
646
647
- const CTxMemPool& mempool = EnsureMemPool (request.context );
647
+ const CTxMemPool& mempool = EnsureAnyMemPool (request.context );
648
648
LOCK (mempool.cs );
649
649
650
650
CTxMemPool::txiter it = mempool.mapTx .find (hash);
@@ -708,7 +708,7 @@ static RPCHelpMan getmempooldescendants()
708
708
709
709
uint256 hash = ParseHashV (request.params [0 ], " parameter 1" );
710
710
711
- const CTxMemPool& mempool = EnsureMemPool (request.context );
711
+ const CTxMemPool& mempool = EnsureAnyMemPool (request.context );
712
712
LOCK (mempool.cs );
713
713
714
714
CTxMemPool::txiter it = mempool.mapTx .find (hash);
@@ -760,7 +760,7 @@ static RPCHelpMan getmempoolentry()
760
760
{
761
761
uint256 hash = ParseHashV (request.params [0 ], " parameter 1" );
762
762
763
- const CTxMemPool& mempool = EnsureMemPool (request.context );
763
+ const CTxMemPool& mempool = EnsureAnyMemPool (request.context );
764
764
LOCK (mempool.cs );
765
765
766
766
CTxMemPool::txiter it = mempool.mapTx .find (hash);
@@ -792,7 +792,7 @@ static RPCHelpMan getblockhash()
792
792
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
793
793
{
794
794
LOCK (cs_main);
795
- const CChain& active_chain = EnsureChainman (request.context ).ActiveChain ();
795
+ const CChain& active_chain = EnsureAnyChainman (request.context ).ActiveChain ();
796
796
797
797
int nHeight = request.params [0 ].get_int ();
798
798
if (nHeight < 0 || nHeight > active_chain.Height ())
@@ -852,7 +852,7 @@ static RPCHelpMan getblockheader()
852
852
const CBlockIndex* tip;
853
853
{
854
854
LOCK (cs_main);
855
- ChainstateManager& chainman = EnsureChainman (request.context );
855
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
856
856
pblockindex = chainman.m_blockman .LookupBlockIndex (hash);
857
857
tip = chainman.ActiveChain ().Tip ();
858
858
}
@@ -977,7 +977,7 @@ static RPCHelpMan getblock()
977
977
const CBlockIndex* tip;
978
978
{
979
979
LOCK (cs_main);
980
- ChainstateManager& chainman = EnsureChainman (request.context );
980
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
981
981
pblockindex = chainman.m_blockman .LookupBlockIndex (hash);
982
982
tip = chainman.ActiveChain ().Tip ();
983
983
@@ -1020,7 +1020,7 @@ static RPCHelpMan pruneblockchain()
1020
1020
throw JSONRPCError (RPC_MISC_ERROR, " Cannot prune blocks because node is not in prune mode." );
1021
1021
1022
1022
LOCK (cs_main);
1023
- ChainstateManager& chainman = EnsureChainman (request.context );
1023
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
1024
1024
1025
1025
int heightParam = request.params [0 ].get_int ();
1026
1026
if (heightParam < 0 )
@@ -1102,7 +1102,7 @@ static RPCHelpMan gettxoutsetinfo()
1102
1102
UniValue ret (UniValue::VOBJ);
1103
1103
1104
1104
CCoinsStats stats;
1105
- CChainState& active_chainstate = EnsureChainman (request.context ).ActiveChainstate ();
1105
+ CChainState& active_chainstate = EnsureAnyChainman (request.context ).ActiveChainstate ();
1106
1106
active_chainstate.ForceFlushStateToDisk ();
1107
1107
1108
1108
const CoinStatsHashType hash_type{request.params [0 ].isNull () ? CoinStatsHashType::HASH_SERIALIZED : ParseHashType (request.params [0 ].get_str ())};
@@ -1114,7 +1114,7 @@ static RPCHelpMan gettxoutsetinfo()
1114
1114
coins_view = &active_chainstate.CoinsDB ();
1115
1115
blockman = &active_chainstate.m_blockman ;
1116
1116
}
1117
- NodeContext& node = EnsureNodeContext (request.context );
1117
+ NodeContext& node = EnsureAnyNodeContext (request.context );
1118
1118
if (GetUTXOStats (coins_view, *blockman, stats, hash_type, node.rpc_interruption_point )) {
1119
1119
ret.pushKV (" height" , (int64_t )stats.nHeight );
1120
1120
ret.pushKV (" bestblock" , stats.hashBlock .GetHex ());
@@ -1186,11 +1186,11 @@ static RPCHelpMan gettxout()
1186
1186
fMempool = request.params [2 ].get_bool ();
1187
1187
1188
1188
Coin coin;
1189
- CChainState& active_chainstate = EnsureChainman (request.context ).ActiveChainstate ();
1189
+ CChainState& active_chainstate = EnsureAnyChainman (request.context ).ActiveChainstate ();
1190
1190
CCoinsViewCache* coins_view = &active_chainstate.CoinsTip ();
1191
1191
1192
1192
if (fMempool ) {
1193
- const CTxMemPool& mempool = EnsureMemPool (request.context );
1193
+ const CTxMemPool& mempool = EnsureAnyMemPool (request.context );
1194
1194
LOCK (mempool.cs );
1195
1195
CCoinsViewMemPool view (coins_view, mempool);
1196
1196
if (!view.GetCoin (out, coin) || mempool.isSpent (out)) {
@@ -1242,7 +1242,7 @@ static RPCHelpMan verifychain()
1242
1242
1243
1243
LOCK (cs_main);
1244
1244
1245
- CChainState& active_chainstate = EnsureChainman (request.context ).ActiveChainstate ();
1245
+ CChainState& active_chainstate = EnsureAnyChainman (request.context ).ActiveChainstate ();
1246
1246
return CVerifyDB ().VerifyDB (Params (), active_chainstate, &active_chainstate.CoinsTip (), check_level, check_depth);
1247
1247
},
1248
1248
};
@@ -1370,7 +1370,7 @@ RPCHelpMan getblockchaininfo()
1370
1370
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1371
1371
{
1372
1372
LOCK (cs_main);
1373
- ChainstateManager& chainman = EnsureChainman (request.context );
1373
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
1374
1374
1375
1375
const CBlockIndex* tip = chainman.ActiveChain ().Tip ();
1376
1376
CHECK_NONFATAL (tip);
@@ -1463,7 +1463,7 @@ static RPCHelpMan getchaintips()
1463
1463
},
1464
1464
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1465
1465
{
1466
- ChainstateManager& chainman = EnsureChainman (request.context );
1466
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
1467
1467
LOCK (cs_main);
1468
1468
1469
1469
/*
@@ -1575,7 +1575,7 @@ static RPCHelpMan getmempoolinfo()
1575
1575
},
1576
1576
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1577
1577
{
1578
- return MempoolInfoToJSON (EnsureMemPool (request.context ));
1578
+ return MempoolInfoToJSON (EnsureAnyMemPool (request.context ));
1579
1579
},
1580
1580
};
1581
1581
}
@@ -1599,7 +1599,7 @@ static RPCHelpMan preciousblock()
1599
1599
uint256 hash (ParseHashV (request.params [0 ], " blockhash" ));
1600
1600
CBlockIndex* pblockindex;
1601
1601
1602
- ChainstateManager& chainman = EnsureChainman (request.context );
1602
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
1603
1603
{
1604
1604
LOCK (cs_main);
1605
1605
pblockindex = chainman.m_blockman .LookupBlockIndex (hash);
@@ -1637,7 +1637,7 @@ static RPCHelpMan invalidateblock()
1637
1637
uint256 hash (ParseHashV (request.params [0 ], " blockhash" ));
1638
1638
BlockValidationState state;
1639
1639
1640
- ChainstateManager& chainman = EnsureChainman (request.context );
1640
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
1641
1641
CBlockIndex* pblockindex;
1642
1642
{
1643
1643
LOCK (cs_main);
@@ -1676,7 +1676,7 @@ static RPCHelpMan reconsiderblock()
1676
1676
},
1677
1677
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1678
1678
{
1679
- ChainstateManager& chainman = EnsureChainman (request.context );
1679
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
1680
1680
uint256 hash (ParseHashV (request.params [0 ], " blockhash" ));
1681
1681
1682
1682
{
@@ -1727,7 +1727,7 @@ static RPCHelpMan getchaintxstats()
1727
1727
},
1728
1728
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1729
1729
{
1730
- ChainstateManager& chainman = EnsureChainman (request.context );
1730
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
1731
1731
const CBlockIndex* pindex;
1732
1732
int blockcount = 30 * 24 * 60 * 60 / Params ().GetConsensus ().nPowTargetSpacing ; // By default: 1 month
1733
1733
@@ -1910,7 +1910,7 @@ static RPCHelpMan getblockstats()
1910
1910
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1911
1911
{
1912
1912
LOCK (cs_main);
1913
- ChainstateManager& chainman = EnsureChainman (request.context );
1913
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
1914
1914
1915
1915
CBlockIndex* pindex;
1916
1916
if (request.params [0 ].isNum ()) {
@@ -2121,7 +2121,7 @@ static RPCHelpMan savemempool()
2121
2121
},
2122
2122
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
2123
2123
{
2124
- const CTxMemPool& mempool = EnsureMemPool (request.context );
2124
+ const CTxMemPool& mempool = EnsureAnyMemPool (request.context );
2125
2125
2126
2126
if (!mempool.IsLoaded ()) {
2127
2127
throw JSONRPCError (RPC_MISC_ERROR, " The mempool was not loaded yet" );
@@ -2313,14 +2313,14 @@ static RPCHelpMan scantxoutset()
2313
2313
CBlockIndex* tip;
2314
2314
{
2315
2315
LOCK (cs_main);
2316
- ChainstateManager& chainman = EnsureChainman (request.context );
2316
+ ChainstateManager& chainman = EnsureAnyChainman (request.context );
2317
2317
chainman.ActiveChainstate ().ForceFlushStateToDisk ();
2318
2318
pcursor = std::unique_ptr<CCoinsViewCursor>(chainman.ActiveChainstate ().CoinsDB ().Cursor ());
2319
2319
CHECK_NONFATAL (pcursor);
2320
2320
tip = chainman.ActiveChain ().Tip ();
2321
2321
CHECK_NONFATAL (tip);
2322
2322
}
2323
- NodeContext& node = EnsureNodeContext (request.context );
2323
+ NodeContext& node = EnsureAnyNodeContext (request.context );
2324
2324
bool res = FindScriptPubKey (g_scan_progress, g_should_abort_scan, count, pcursor.get (), needles, coins, node.rpc_interruption_point );
2325
2325
result.pushKV (" success" , res);
2326
2326
result.pushKV (" txouts" , count);
@@ -2394,7 +2394,7 @@ static RPCHelpMan getblockfilter()
2394
2394
bool block_was_connected;
2395
2395
{
2396
2396
LOCK (cs_main);
2397
- block_index = EnsureChainman (request.context ).m_blockman .LookupBlockIndex (block_hash);
2397
+ block_index = EnsureAnyChainman (request.context ).m_blockman .LookupBlockIndex (block_hash);
2398
2398
if (!block_index) {
2399
2399
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Block not found" );
2400
2400
}
@@ -2477,7 +2477,7 @@ static RPCHelpMan dumptxoutset()
2477
2477
2478
2478
FILE* file{fsbridge::fopen (temppath, " wb" )};
2479
2479
CAutoFile afile{file, SER_DISK, CLIENT_VERSION};
2480
- NodeContext& node = EnsureNodeContext (request.context );
2480
+ NodeContext& node = EnsureAnyNodeContext (request.context );
2481
2481
UniValue result = CreateUTXOSnapshot (node, node.chainman ->ActiveChainstate (), afile);
2482
2482
fs::rename (temppath, path);
2483
2483
0 commit comments