| 249 | } |
| 250 | |
| 251 | static UniValue getmininginfo(const JSONRPCRequest& request) |
| 252 | { |
| 253 | if (request.fHelp || request.params.size() != 0) |
| 254 | throw std::runtime_error( |
| 255 | "getmininginfo\n" |
| 256 | "\nReturns a json object containing mining-related information." |
| 257 | "\nResult:\n" |
| 258 | "{\n" |
| 259 | " \"blocks\": nnn, (numeric) The current block\n" |
| 260 | " \"currentblockweight\": nnn, (numeric) The last block weight\n" |
| 261 | " \"currentblocktx\": nnn, (numeric) The last block transaction\n" |
| 262 | " \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n" |
| 263 | " \"networkhashps\": nnn, (numeric) The network hashes per second\n" |
| 264 | " \"pooledtx\": n (numeric) The size of the mempool\n" |
| 265 | " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" |
| 266 | " \"warnings\": \"...\" (string) any network and blockchain warnings\n" |
| 267 | "}\n" |
| 268 | "\nExamples:\n" |
| 269 | + HelpExampleCli("getmininginfo", "") |
| 270 | + HelpExampleRpc("getmininginfo", "") |
| 271 | ); |
| 272 | |
| 273 | |
| 274 | LOCK(cs_main); |
| 275 | |
| 276 | UniValue obj(UniValue::VOBJ); |
| 277 | obj.pushKV("blocks", (int)chainActive.Height()); |
| 278 | obj.pushKV("currentblockweight", (uint64_t)nLastBlockWeight); |
| 279 | obj.pushKV("currentblocktx", (uint64_t)nLastBlockTx); |
| 280 | obj.pushKV("difficulty", (double)GetDifficulty(chainActive.Tip())); |
| 281 | obj.pushKV("networkhashps", getnetworkhashps(request)); |
| 282 | obj.pushKV("pooledtx", (uint64_t)mempool.size()); |
| 283 | obj.pushKV("chain", Params().NetworkIDString()); |
| 284 | obj.pushKV("warnings", GetWarnings("statusbar")); |
| 285 | return obj; |
| 286 | } |
| 287 | |
| 288 | |
| 289 | // NOTE: Unlike wallet RPC (which use BTG values), mining RPCs follow GBT (BIP 22) in using satoshi amounts |
nothing calls this directly
no test coverage detected