Allow mining RPCs with --disable-wallet
The following mining-related RPC calls don't use the wallet: - getnetworkhashps - getmininginfo - getblocktemplate - submitblock Enable them when compiling with --disable-wallet.
This commit is contained in:
@@ -20,7 +20,8 @@
|
||||
using namespace json_spirit;
|
||||
using namespace std;
|
||||
|
||||
// Key used by getwork/getblocktemplate miners.
|
||||
#ifdef ENABLE_WALLET
|
||||
// Key used by getwork miners.
|
||||
// Allocated in InitRPCMining, free'd in ShutdownRPCMining
|
||||
static CReserveKey* pMiningKey = NULL;
|
||||
|
||||
@@ -40,6 +41,14 @@ void ShutdownRPCMining()
|
||||
|
||||
delete pMiningKey; pMiningKey = NULL;
|
||||
}
|
||||
#else
|
||||
void InitRPCMining()
|
||||
{
|
||||
}
|
||||
void ShutdownRPCMining()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
// Return average network hashes per second based on the last 'lookup' blocks,
|
||||
// or from the last difficulty change if 'lookup' is nonpositive.
|
||||
@@ -99,7 +108,7 @@ Value getnetworkhashps(const Array& params, bool fHelp)
|
||||
return GetNetworkHashPS(params.size() > 0 ? params[0].get_int() : 120, params.size() > 1 ? params[1].get_int() : -1);
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
Value getgenerate(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 0)
|
||||
@@ -197,7 +206,6 @@ Value setgenerate(const Array& params, bool fHelp)
|
||||
return Value::null;
|
||||
}
|
||||
|
||||
|
||||
Value gethashespersec(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 0)
|
||||
@@ -216,6 +224,7 @@ Value gethashespersec(const Array& params, bool fHelp)
|
||||
return (boost::int64_t)0;
|
||||
return (boost::int64_t)dHashesPerSec;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Value getmininginfo(const Array& params, bool fHelp)
|
||||
@@ -248,16 +257,19 @@ Value getmininginfo(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
|
||||
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
||||
obj.push_back(Pair("errors", GetWarnings("statusbar")));
|
||||
obj.push_back(Pair("generate", getgenerate(params, false)));
|
||||
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
|
||||
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
|
||||
obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
|
||||
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
|
||||
obj.push_back(Pair("testnet", TestNet()));
|
||||
#ifdef ENABLE_WALLET
|
||||
obj.push_back(Pair("generate", getgenerate(params, false)));
|
||||
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
|
||||
#endif
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
Value getwork(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() > 1)
|
||||
@@ -381,7 +393,7 @@ Value getwork(const Array& params, bool fHelp)
|
||||
return CheckWork(pblock, *pwalletMain, *pMiningKey);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Value getblocktemplate(const Array& params, bool fHelp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user