Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 768 Lines • ▼ Show 20 Lines | if (!sc.found) { | ||||
return "inconclusive"; | return "inconclusive"; | ||||
} | } | ||||
return BIP22ValidationResult(config, sc.state); | return BIP22ValidationResult(config, sc.state); | ||||
} | } | ||||
static UniValue estimatefee(const Config &config, | static UniValue estimatefee(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() > 1) { | ||||
Fabien: Shouldn't it be `> 0`, or is it intentional to allow for using the deprecated parameter… | |||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"estimatefee nblocks\n" | "estimatefee nblocks\n" | ||||
"\nEstimates the approximate fee per kilobyte needed for a " | "\nEstimates the approximate fee per kilobyte needed for a " | ||||
"transaction to begin\n" | "transaction\n" | ||||
"confirmation within nblocks blocks.\n" | |||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. nblocks (numeric, required)\n" | "1. nblocks (numeric, DEPRECATED)\n" | ||||
FabienUnsubmitted Done Inline ActionsMore thought: as it is not used anyway, is it really necessary to mark it as deprecated rather than deleting it ? Leaving it would require the help message to be cleaned up later to remove it. Fabien: More thought: as it is not used anyway, is it really necessary to mark it as deprecated rather… | |||||
jasonbcoxAuthorUnsubmitted Done Inline ActionsOriginally I was going to clean it up later. But after thinking about your comment above, I think we can just provide a message like: if (request.params.size() == 1) { // DEPRECATED error message } jasonbcox: Originally I was going to clean it up later. But after thinking about your comment above, I… | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"n (numeric) estimated fee-per-kilobyte\n" | "n (numeric) estimated fee-per-kilobyte\n" | ||||
"\n" | |||||
"A negative value is returned if not enough transactions and " | |||||
"blocks\n" | |||||
"have been observed to make an estimate.\n" | |||||
"-1 is always returned for nblocks == 1 as it is impossible to " | |||||
"calculate\n" | |||||
"a fee that is high enough to get reliably included in the next " | |||||
"block.\n" | |||||
"\nExample:\n" + | "\nExample:\n" + | ||||
HelpExampleCli("estimatefee", "6")); | HelpExampleCli("estimatefee", "")); | ||||
} | |||||
RPCTypeCheck(request.params, {UniValue::VNUM}); | |||||
int nBlocks = request.params[0].get_int(); | |||||
if (nBlocks < 1) { | |||||
nBlocks = 1; | |||||
} | |||||
CFeeRate feeRate = g_mempool.estimateFee(nBlocks); | |||||
if (feeRate == CFeeRate(Amount::zero())) { | |||||
return -1.0; | |||||
} | } | ||||
return ValueFromAmount(feeRate.GetFeePerK()); | return ValueFromAmount(g_mempool.estimateFee().GetFeePerK()); | ||||
} | } | ||||
// clang-format off | // clang-format off | ||||
static const ContextFreeRPCCommand commands[] = { | static const ContextFreeRPCCommand commands[] = { | ||||
// category name actor (function) argNames | // category name actor (function) argNames | ||||
// ---------- ------------------------ ---------------------- ---------- | // ---------- ------------------------ ---------------------- ---------- | ||||
{"mining", "getnetworkhashps", getnetworkhashps, {"nblocks", "height"}}, | {"mining", "getnetworkhashps", getnetworkhashps, {"nblocks", "height"}}, | ||||
{"mining", "getmininginfo", getmininginfo, {}}, | {"mining", "getmininginfo", getmininginfo, {}}, | ||||
Show All 14 Lines |
Shouldn't it be > 0, or is it intentional to allow for using the deprecated parameter without returning the help message ?
If the later is correct this can be confusing to user. If your argument is accepted with no error you can expect it to be taken into account. And if the help showing the deprecation doesn't show up, you may never notice that the argument is actually deprecated.