Browse Source

Add new "getmininginfo" JSON-RPC method, with mining-only fields moved out of "getinfo"

0.8
Luke Dashjr 13 years ago
parent
commit
6950bb6200
  1. 24
      src/bitcoinrpc.cpp

24
src/bitcoinrpc.cpp

@ -347,10 +347,7 @@ Value getinfo(const Array& params, bool fHelp) @@ -347,10 +347,7 @@ Value getinfo(const Array& params, bool fHelp)
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("connections", (int)vNodes.size()));
obj.push_back(Pair("proxy", (fUseProxy ? addrProxy.ToStringIPPort() : string())));
obj.push_back(Pair("generate", (bool)fGenerateBitcoins));
obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1)));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
obj.push_back(Pair("testnet", fTestNet));
obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", pwalletMain->GetKeyPoolSize()));
@ -362,6 +359,25 @@ Value getinfo(const Array& params, bool fHelp) @@ -362,6 +359,25 @@ Value getinfo(const Array& params, bool fHelp)
}
Value getmininginfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getmininginfo\n"
"Returns an object containing mining-related information.");
Object obj;
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("generate", (bool)fGenerateBitcoins));
obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1)));
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
obj.push_back(Pair("testnet", fTestNet));
return obj;
}
Value getnewaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
@ -1986,6 +2002,7 @@ pair<string, rpcfn_type> pCallTable[] = @@ -1986,6 +2002,7 @@ pair<string, rpcfn_type> pCallTable[] =
make_pair("setgenerate", &setgenerate),
make_pair("gethashespersec", &gethashespersec),
make_pair("getinfo", &getinfo),
make_pair("getmininginfo", &getmininginfo),
make_pair("getnewaddress", &getnewaddress),
make_pair("getaccountaddress", &getaccountaddress),
make_pair("setaccount", &setaccount),
@ -2036,6 +2053,7 @@ string pAllowInSafeMode[] = @@ -2036,6 +2053,7 @@ string pAllowInSafeMode[] =
"setgenerate",
"gethashespersec",
"getinfo",
"getmininginfo",
"getnewaddress",
"getaccountaddress",
"getaccount",

Loading…
Cancel
Save