mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-02 22:03:27 +02:00
rpc: factor out RpcInterruptionPoint from dumptxoutset
This commit is contained in:
@@ -2329,9 +2329,7 @@ UniValue dumptxoutset(const JSONRPCRequest& request)
|
|||||||
unsigned int iter{0};
|
unsigned int iter{0};
|
||||||
|
|
||||||
while (pcursor->Valid()) {
|
while (pcursor->Valid()) {
|
||||||
if (iter % 5000 == 0 && !IsRPCRunning()) {
|
if (iter % 5000 == 0) RpcInterruptionPoint();
|
||||||
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Shutting down");
|
|
||||||
}
|
|
||||||
++iter;
|
++iter;
|
||||||
if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
|
if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
|
||||||
afile << key;
|
afile << key;
|
||||||
|
@@ -11,9 +11,9 @@
|
|||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
|
|
||||||
#include <boost/signals2/signal.hpp>
|
|
||||||
#include <boost/algorithm/string/classification.hpp>
|
#include <boost/algorithm/string/classification.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
|
#include <boost/signals2/signal.hpp>
|
||||||
|
|
||||||
#include <memory> // for unique_ptr
|
#include <memory> // for unique_ptr
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -309,6 +309,11 @@ bool IsRPCRunning()
|
|||||||
return g_rpc_running;
|
return g_rpc_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RpcInterruptionPoint()
|
||||||
|
{
|
||||||
|
if (!IsRPCRunning()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Shutting down");
|
||||||
|
}
|
||||||
|
|
||||||
void SetRPCWarmupStatus(const std::string& newStatus)
|
void SetRPCWarmupStatus(const std::string& newStatus)
|
||||||
{
|
{
|
||||||
LOCK(cs_rpcWarmup);
|
LOCK(cs_rpcWarmup);
|
||||||
|
@@ -9,10 +9,10 @@
|
|||||||
#include <amount.h>
|
#include <amount.h>
|
||||||
#include <rpc/request.h>
|
#include <rpc/request.h>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
@@ -29,6 +29,9 @@ namespace RPCServer
|
|||||||
/** Query whether RPC is running */
|
/** Query whether RPC is running */
|
||||||
bool IsRPCRunning();
|
bool IsRPCRunning();
|
||||||
|
|
||||||
|
/** Throw JSONRPCError if RPC is not running */
|
||||||
|
void RpcInterruptionPoint();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the RPC warmup status. When this is done, all RPC calls will error out
|
* Set the RPC warmup status. When this is done, all RPC calls will error out
|
||||||
* immediately with RPC_IN_WARMUP.
|
* immediately with RPC_IN_WARMUP.
|
||||||
|
Reference in New Issue
Block a user