MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / getmininginfo

Function getmininginfo

src/rpcmining.cpp:225–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223
224
225UniValue 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 " \"generate\": true|false (boolean) If the generation is on or off (see getgenerate or setgenerate calls)\n"
239 " \"genproclimit\": n (numeric) The processor limit for generation. -1 if no generation. (see getgenerate or setgenerate calls)\n"
240 " \"pooledtx\": n (numeric) The size of the mem pool\n"
241 " \"testnet\": true|false (boolean) If using testnet or not\n"
242 " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
243 " \"sizelimit\" : n, (numeric) The block size limit as of the last block\n"
244 "}\n"
245 "\nExamples:\n"
246 + HelpExampleCli("getmininginfo", "")
247 + HelpExampleRpc("getmininginfo", "")
248 );
249
250
251 LOCK(cs_main);
252
253 UniValue obj(UniValue::VOBJ);
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()));
258 obj.push_back(Pair("errors", GetWarnings("statusbar")));
259 obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
260 obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
261 obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
262 obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
263 obj.push_back(Pair("chain", Params().NetworkIDString()));
264 obj.push_back(Pair("sizelimit", chainActive.Tip()->nMaxBlockSize));
265#ifdef ENABLE_WALLET
266 obj.push_back(Pair("generate", getgenerate(params, false)));
267#endif
268 return obj;
269}
270
271
272// NOTE: Unlike wallet RPC (which use BTC values), mining RPCs follow GBT (BIP 22) in using satoshi amounts

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
PairFunction · 0.85
GetDifficultyFunction · 0.85
GetWarningsFunction · 0.85
GetArgFunction · 0.85
getnetworkhashpsFunction · 0.85
getgenerateFunction · 0.85
HeightMethod · 0.80
NetworkIDStringMethod · 0.80
ParamsClass · 0.70

Tested by

no test coverage detected