| 251 | } |
| 252 | |
| 253 | static 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 | |
| 280 | static UniValue RPCLockedMemoryInfo() |
| 281 | { |
nothing calls this directly
no test coverage detected