@@ -1004,7 +1004,8 @@ static UniValue gettxoutsetinfo(const JSONRPCRequest& request)
1004
1004
const CoinStatsHashType hash_type = ParseHashType (request.params [0 ], CoinStatsHashType::HASH_SERIALIZED);
1005
1005
1006
1006
CCoinsView* coins_view = WITH_LOCK (cs_main, return &ChainstateActive ().CoinsDB ());
1007
- if (GetUTXOStats (coins_view, stats, hash_type, RpcInterruptionPoint)) {
1007
+ NodeContext& node = EnsureNodeContext (request.context );
1008
+ if (GetUTXOStats (coins_view, stats, hash_type, node.rpc_interruption_point )) {
1008
1009
ret.pushKV (" height" , (int64_t )stats.nHeight );
1009
1010
ret.pushKV (" bestblock" , stats.hashBlock .GetHex ());
1010
1011
ret.pushKV (" transactions" , (int64_t )stats.nTransactions );
@@ -1974,16 +1975,18 @@ static UniValue savemempool(const JSONRPCRequest& request)
1974
1975
return NullUniValue;
1975
1976
}
1976
1977
1978
+ namespace {
1977
1979
// ! Search for a given set of pubkey scripts
1978
- bool FindScriptPubKey (std::atomic<int >& scan_progress, const std::atomic<bool >& should_abort, int64_t & count, CCoinsViewCursor* cursor, const std::set<CScript>& needles, std::map<COutPoint, Coin>& out_results) {
1980
+ bool FindScriptPubKey (std::atomic<int >& scan_progress, const std::atomic<bool >& should_abort, int64_t & count, CCoinsViewCursor* cursor, const std::set<CScript>& needles, std::map<COutPoint, Coin>& out_results, std::function<void ()>& interruption_point)
1981
+ {
1979
1982
scan_progress = 0 ;
1980
1983
count = 0 ;
1981
1984
while (cursor->Valid ()) {
1982
1985
COutPoint key;
1983
1986
Coin coin;
1984
1987
if (!cursor->GetKey (key) || !cursor->GetValue (coin)) return false ;
1985
1988
if (++count % 8192 == 0 ) {
1986
- RpcInterruptionPoint ();
1989
+ interruption_point ();
1987
1990
if (should_abort) {
1988
1991
// allow to abort the scan via the abort reference
1989
1992
return false ;
@@ -2002,6 +2005,7 @@ bool FindScriptPubKey(std::atomic<int>& scan_progress, const std::atomic<bool>&
2002
2005
scan_progress = 100 ;
2003
2006
return true ;
2004
2007
}
2008
+ } // namespace
2005
2009
2006
2010
/* * RAII object to prevent concurrency issue when scanning the txout set */
2007
2011
static std::atomic<int > g_scan_progress;
@@ -2150,7 +2154,8 @@ UniValue scantxoutset(const JSONRPCRequest& request)
2150
2154
tip = ::ChainActive ().Tip ();
2151
2155
CHECK_NONFATAL (tip);
2152
2156
}
2153
- bool res = FindScriptPubKey (g_scan_progress, g_should_abort_scan, count, pcursor.get (), needles, coins);
2157
+ NodeContext& node = EnsureNodeContext (request.context );
2158
+ bool res = FindScriptPubKey (g_scan_progress, g_should_abort_scan, count, pcursor.get (), needles, coins, node.rpc_interruption_point );
2154
2159
result.pushKV (" success" , res);
2155
2160
result.pushKV (" txouts" , count);
2156
2161
result.pushKV (" height" , tip->nHeight );
@@ -2305,6 +2310,7 @@ UniValue dumptxoutset(const JSONRPCRequest& request)
2305
2310
std::unique_ptr<CCoinsViewCursor> pcursor;
2306
2311
CCoinsStats stats;
2307
2312
CBlockIndex* tip;
2313
+ NodeContext& node = EnsureNodeContext (request.context );
2308
2314
2309
2315
{
2310
2316
// We need to lock cs_main to ensure that the coinsdb isn't written to
@@ -2323,7 +2329,7 @@ UniValue dumptxoutset(const JSONRPCRequest& request)
2323
2329
2324
2330
::ChainstateActive ().ForceFlushStateToDisk();
2325
2331
2326
- if (!GetUTXOStats (&::ChainstateActive ().CoinsDB (), stats, CoinStatsHashType::NONE, RpcInterruptionPoint )) {
2332
+ if (!GetUTXOStats (&::ChainstateActive ().CoinsDB (), stats, CoinStatsHashType::NONE, node. rpc_interruption_point )) {
2327
2333
throw JSONRPCError (RPC_INTERNAL_ERROR, " Unable to read UTXO set" );
2328
2334
}
2329
2335
@@ -2341,7 +2347,7 @@ UniValue dumptxoutset(const JSONRPCRequest& request)
2341
2347
unsigned int iter{0 };
2342
2348
2343
2349
while (pcursor->Valid ()) {
2344
- if (iter % 5000 == 0 ) RpcInterruptionPoint ();
2350
+ if (iter % 5000 == 0 ) node. rpc_interruption_point ();
2345
2351
++iter;
2346
2352
if (pcursor->GetKey (key) && pcursor->GetValue (coin)) {
2347
2353
afile << key;
0 commit comments