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