Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 2) { | ||||
"x (numeric) Hashes per second estimated\n" | "x (numeric) Hashes per second estimated\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getnetworkhashps", "") + | HelpExampleCli("getnetworkhashps", "") + | ||||
HelpExampleRpc("getnetworkhashps", "")); | HelpExampleRpc("getnetworkhashps", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
return GetNetworkHashPS( | return GetNetworkHashPS( | ||||
request.params.size() > 0 ? request.params[0].get_int() : 120, | !request.params[0].isNull() ? request.params[0].get_int() : 120, | ||||
request.params.size() > 1 ? request.params[1].get_int() : -1); | !request.params[1].isNull() ? request.params[1].get_int() : -1); | ||||
} | } | ||||
UniValue generateBlocks(const Config &config, | UniValue generateBlocks(const Config &config, | ||||
std::shared_ptr<CReserveScript> coinbaseScript, | std::shared_ptr<CReserveScript> coinbaseScript, | ||||
int nGenerate, uint64_t nMaxTries, bool keepScript) { | int nGenerate, uint64_t nMaxTries, bool keepScript) { | ||||
static const int nInnerLoopCount = 0x100000; | static const int nInnerLoopCount = 0x100000; | ||||
int nHeightStart = 0; | int nHeightStart = 0; | ||||
int nHeightEnd = 0; | int nHeightEnd = 0; | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 2 || | ||||
"[ blockhashes ] (array) hashes of blocks generated\n" | "[ blockhashes ] (array) hashes of blocks generated\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nGenerate 11 blocks to myaddress\n" + | "\nGenerate 11 blocks to myaddress\n" + | ||||
HelpExampleCli("generatetoaddress", "11 \"myaddress\"")); | HelpExampleCli("generatetoaddress", "11 \"myaddress\"")); | ||||
} | } | ||||
int nGenerate = request.params[0].get_int(); | int nGenerate = request.params[0].get_int(); | ||||
uint64_t nMaxTries = 1000000; | uint64_t nMaxTries = 1000000; | ||||
if (request.params.size() > 2) { | if (!request.params[2].isNull()) { | ||||
nMaxTries = request.params[2].get_int(); | nMaxTries = request.params[2].get_int(); | ||||
} | } | ||||
CTxDestination destination = | CTxDestination destination = | ||||
DecodeDestination(request.params[1].get_str(), config.GetChainParams()); | DecodeDestination(request.params[1].get_str(), config.GetChainParams()); | ||||
if (!IsValidDestination(destination)) { | if (!IsValidDestination(destination)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Error: Invalid address"); | "Error: Invalid address"); | ||||
▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 1) { | ||||
HelpExampleRpc("getblocktemplate", "")); | HelpExampleRpc("getblocktemplate", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
std::string strMode = "template"; | std::string strMode = "template"; | ||||
UniValue lpval = NullUniValue; | UniValue lpval = NullUniValue; | ||||
std::set<std::string> setClientRules; | std::set<std::string> setClientRules; | ||||
if (request.params.size() > 0) { | if (!request.params[0].isNull()) { | ||||
const UniValue &oparam = request.params[0].get_obj(); | const UniValue &oparam = request.params[0].get_obj(); | ||||
const UniValue &modeval = find_value(oparam, "mode"); | const UniValue &modeval = find_value(oparam, "mode"); | ||||
if (modeval.isStr()) { | if (modeval.isStr()) { | ||||
strMode = modeval.get_str(); | strMode = modeval.get_str(); | ||||
} else if (modeval.isNull()) { | } else if (modeval.isNull()) { | ||||
/* Do nothing */ | /* Do nothing */ | ||||
} else { | } else { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); | throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); | ||||
▲ Show 20 Lines • Show All 364 Lines • Show Last 20 Lines |