| 223 | |
| 224 | |
| 225 | UniValue getmininginfo(const UniValue& params, bool fHelp) |
| 226 | { |
| 227 | if (fHelp || params.size() != 0) |
| 228 | throw runtime_error( |
| 229 | "getmininginfo\n" |
| 230 | "\nReturns a json object containing mining-related information." |
| 231 | "\nResult:\n" |
| 232 | "{\n" |
| 233 | " \"blocks\": nnn, (numeric) The current block\n" |
| 234 | " \"currentblocksize\": nnn, (numeric) The last block size\n" |
| 235 | " \"currentblocktx\": nnn, (numeric) The last block transaction\n" |
| 236 | " \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n" |
| 237 | " \"errors\": \"...\" (string) Current errors\n" |
| 238 | #ifdef ENABLE_CPUMINER |
| 239 | " \"generate\": true|false (boolean) If the generation is on or off (see getgenerate or setgenerate calls)\n" |
| 240 | " \"genproclimit\": n (numeric) The processor limit for generation. -1 if no generation. (see getgenerate or setgenerate calls)\n" |
| 241 | " \"hashespersec\": n (numeric) The hashes per second of the generation, or 0 if no generation.\n" |
| 242 | #endif |
| 243 | " \"pooledtx\": n (numeric) The size of the mem pool\n" |
| 244 | " \"testnet\": true|false (boolean) If using testnet or not\n" |
| 245 | " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" |
| 246 | " \"algo\" : \"phi2\" (string) The current proof-of-work algorithm name\n" |
| 247 | " \"segwit\": true|false (boolean) If segwit txs are enabled or not\n" |
| 248 | "}\n" |
| 249 | "\nExamples:\n" + |
| 250 | HelpExampleCli("getmininginfo", "") + HelpExampleRpc("getmininginfo", "")); |
| 251 | |
| 252 | UniValue obj(UniValue::VOBJ); |
| 253 | CBlockIndex* powTip = GetLastBlockOfType(0); |
| 254 | obj.push_back(Pair("blocks", (int)chainActive.Height())); |
| 255 | obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); |
| 256 | obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); |
| 257 | obj.push_back(Pair("difficulty", (double)GetDifficulty(powTip))); |
| 258 | obj.push_back(Pair("errors", GetWarnings("statusbar"))); |
| 259 | obj.push_back(Pair("networkhashps", getnetworkhashps(params, false))); |
| 260 | obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); |
| 261 | obj.push_back(Pair("testnet", Params().NetworkIDString() != "main")); |
| 262 | obj.push_back(Pair("chain", Params().NetworkIDString())); |
| 263 | if ((chainActive.Height()+1) < Params().SwitchPhi2Block()) |
| 264 | obj.push_back(Pair("algo", "phi1612")); |
| 265 | else if ((chainActive.Height()+1) < Params().SwitchRX2Block()) |
| 266 | obj.push_back(Pair("algo", "phi2")); |
| 267 | else |
| 268 | obj.push_back(Pair("algo", "rx2")); |
| 269 | |
| 270 | |
| 271 | obj.push_back(Pair("segwit", IsWitnessEnabled(chainActive.Tip(), Params().GetConsensus()) )); |
| 272 | #ifdef ENABLE_CPUMINER |
| 273 | obj.push_back(Pair("generate", getgenerate(params, false))); |
| 274 | obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1))); |
| 275 | obj.push_back(Pair("hashespersec", gethashespersec(params, false))); |
| 276 | #endif |
| 277 | return obj; |
| 278 | } |
| 279 | |
| 280 | |
| 281 | // NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts |
nothing calls this directly
no test coverage detected