Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/misc.cpp
Show All 11 Lines | |||||
#include <node/context.h> | #include <node/context.h> | ||||
#include <outputtype.h> | #include <outputtype.h> | ||||
#include <rpc/blockchain.h> | #include <rpc/blockchain.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <rpc/util.h> | #include <rpc/util.h> | ||||
#include <scheduler.h> | #include <scheduler.h> | ||||
#include <script/descriptor.h> | #include <script/descriptor.h> | ||||
#include <util/check.h> | #include <util/check.h> | ||||
#include <util/ref.h> | |||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/validation.h> | #include <util/validation.h> | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <tuple> | #include <tuple> | ||||
▲ Show 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | static UniValue setmocktime(const Config &config, | ||||
RPCTypeCheck(request.params, {UniValue::VNUM}); | RPCTypeCheck(request.params, {UniValue::VNUM}); | ||||
int64_t time = request.params[0].get_int64(); | int64_t time = request.params[0].get_int64(); | ||||
if (time < 0) { | if (time < 0) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Timestamp must be 0 or greater"); | "Timestamp must be 0 or greater"); | ||||
} | } | ||||
SetMockTime(time); | SetMockTime(time); | ||||
if (g_rpc_node) { | if (request.context.Has<NodeContext>()) { | ||||
for (const auto &chain_client : g_rpc_node->chain_clients) { | for (const auto &chain_client : | ||||
request.context.Get<NodeContext>().chain_clients) { | |||||
chain_client->setMockTime(time); | chain_client->setMockTime(time); | ||||
} | } | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue mockscheduler(const Config &config, | static UniValue mockscheduler(const Config &config, | ||||
Show All 19 Lines | static UniValue mockscheduler(const Config &config, | ||||
RPCTypeCheck(request.params, {UniValue::VNUM}); | RPCTypeCheck(request.params, {UniValue::VNUM}); | ||||
int64_t delta_seconds = request.params[0].get_int64(); | int64_t delta_seconds = request.params[0].get_int64(); | ||||
if ((delta_seconds <= 0) || (delta_seconds > 3600)) { | if ((delta_seconds <= 0) || (delta_seconds > 3600)) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"delta_time must be between 1 and 3600 seconds (1 hr)"); | "delta_time must be between 1 and 3600 seconds (1 hr)"); | ||||
} | } | ||||
// protect against null pointer dereference | // protect against null pointer dereference | ||||
CHECK_NONFATAL(g_rpc_node); | CHECK_NONFATAL(request.context.Has<NodeContext>()); | ||||
CHECK_NONFATAL(g_rpc_node->scheduler); | NodeContext &node = request.context.Get<NodeContext>(); | ||||
g_rpc_node->scheduler->MockForward(std::chrono::seconds(delta_seconds)); | CHECK_NONFATAL(node.scheduler); | ||||
node.scheduler->MockForward(std::chrono::seconds(delta_seconds)); | |||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static UniValue RPCLockedMemoryInfo() { | static UniValue RPCLockedMemoryInfo() { | ||||
LockedPool::Stats stats = LockedPoolManager::Instance().stats(); | LockedPool::Stats stats = LockedPoolManager::Instance().stats(); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("used", uint64_t(stats.used)); | obj.pushKV("used", uint64_t(stats.used)); | ||||
▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines |