MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / setmocktime

Function setmocktime

src/rpc/misc.cpp:253–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253static UniValue setmocktime(const JSONRPCRequest& request)
254{
255 if (request.fHelp || request.params.size() != 1)
256 throw std::runtime_error(
257 "setmocktime timestamp\n"
258 "\nSet the local time to given timestamp (-regtest only)\n"
259 "\nArguments:\n"
260 "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n"
261 " Pass 0 to go back to using the system time."
262 );
263
264 if (!Params().MineBlocksOnDemand())
265 throw std::runtime_error("setmocktime for regression testing (-regtest mode) only");
266
267 // For now, don't change mocktime if we're in the middle of validation, as
268 // this could have an effect on mempool time-based eviction, as well as
269 // IsCurrentForFeeEstimation() and IsInitialBlockDownload().
270 // TODO: figure out the right way to synchronize around mocktime, and
271 // ensure all call sites of GetTime() are accessing this safely.
272 LOCK(cs_main);
273
274 RPCTypeCheck(request.params, {UniValue::VNUM});
275 SetMockTime(request.params[0].get_int64());
276
277 return NullUniValue;
278}
279
280static UniValue RPCLockedMemoryInfo()
281{

Callers

nothing calls this directly

Calls 6

RPCTypeCheckFunction · 0.85
SetMockTimeFunction · 0.85
MineBlocksOnDemandMethod · 0.80
get_int64Method · 0.80
ParamsClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected