Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show All 20 Lines | |||||
#include "util.h" | #include "util.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
#include "validationinterface.h" | #include "validationinterface.h" | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <memory> | #include <memory> | ||||
#include <boost/assign/list_of.hpp> | |||||
#include <boost/shared_ptr.hpp> | #include <boost/shared_ptr.hpp> | ||||
#include <univalue.h> | #include <univalue.h> | ||||
/** | /** | ||||
* Return average network hashes per second based on the last 'lookup' blocks, | * Return average network hashes per second based on the last 'lookup' blocks, | ||||
* or from the last difficulty change if 'lookup' is nonpositive. If 'height' is | * or from the last difficulty change if 'lookup' is nonpositive. If 'height' is | ||||
* nonnegative, compute the estimate at the time when a given block was found. | * nonnegative, compute the estimate at the time when a given block was found. | ||||
▲ Show 20 Lines • Show All 893 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"-1 is always returned for nblocks == 1 as it is impossible to " | "-1 is always returned for nblocks == 1 as it is impossible to " | ||||
"calculate\n" | "calculate\n" | ||||
"a fee that is high enough to get reliably included in the next " | "a fee that is high enough to get reliably included in the next " | ||||
"block.\n" | "block.\n" | ||||
"\nExample:\n" + | "\nExample:\n" + | ||||
HelpExampleCli("estimatefee", "6")); | HelpExampleCli("estimatefee", "6")); | ||||
} | } | ||||
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); | RPCTypeCheck(request.params, {UniValue::VNUM}); | ||||
int nBlocks = request.params[0].get_int(); | int nBlocks = request.params[0].get_int(); | ||||
if (nBlocks < 1) { | if (nBlocks < 1) { | ||||
nBlocks = 1; | nBlocks = 1; | ||||
} | } | ||||
CFeeRate feeRate = mempool.estimateFee(nBlocks); | CFeeRate feeRate = mempool.estimateFee(nBlocks); | ||||
if (feeRate == CFeeRate(0)) { | if (feeRate == CFeeRate(0)) { | ||||
Show All 18 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"\n" | "\n" | ||||
"A negative value is returned if not enough " | "A negative value is returned if not enough " | ||||
"transactions and blocks\n" | "transactions and blocks\n" | ||||
"have been observed to make an estimate.\n" | "have been observed to make an estimate.\n" | ||||
"\nExample:\n" + | "\nExample:\n" + | ||||
HelpExampleCli("estimatepriority", "6")); | HelpExampleCli("estimatepriority", "6")); | ||||
} | } | ||||
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); | RPCTypeCheck(request.params, {UniValue::VNUM}); | ||||
int nBlocks = request.params[0].get_int(); | int nBlocks = request.params[0].get_int(); | ||||
if (nBlocks < 1) { | if (nBlocks < 1) { | ||||
nBlocks = 1; | nBlocks = 1; | ||||
} | } | ||||
return mempool.estimatePriority(nBlocks); | return mempool.estimatePriority(nBlocks); | ||||
} | } | ||||
Show All 23 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"A negative value is returned if not enough transactions and " | "A negative value is returned if not enough transactions and " | ||||
"blocks\n" | "blocks\n" | ||||
"have been observed to make an estimate for any number of blocks.\n" | "have been observed to make an estimate for any number of blocks.\n" | ||||
"However it will not return a value below the mempool reject fee.\n" | "However it will not return a value below the mempool reject fee.\n" | ||||
"\nExample:\n" + | "\nExample:\n" + | ||||
HelpExampleCli("estimatesmartfee", "6")); | HelpExampleCli("estimatesmartfee", "6")); | ||||
} | } | ||||
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); | RPCTypeCheck(request.params, {UniValue::VNUM}); | ||||
int nBlocks = request.params[0].get_int(); | int nBlocks = request.params[0].get_int(); | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
int answerFound; | int answerFound; | ||||
CFeeRate feeRate = mempool.estimateSmartFee(nBlocks, &answerFound); | CFeeRate feeRate = mempool.estimateSmartFee(nBlocks, &answerFound); | ||||
result.push_back(Pair( | result.push_back(Pair( | ||||
"feerate", | "feerate", | ||||
Show All 27 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
"blocks\n" | "blocks\n" | ||||
"have been observed to make an estimate for any number of blocks.\n" | "have been observed to make an estimate for any number of blocks.\n" | ||||
"However if the mempool reject fee is set it will return 1e9 * " | "However if the mempool reject fee is set it will return 1e9 * " | ||||
"MAX_MONEY.\n" | "MAX_MONEY.\n" | ||||
"\nExample:\n" + | "\nExample:\n" + | ||||
HelpExampleCli("estimatesmartpriority", "6")); | HelpExampleCli("estimatesmartpriority", "6")); | ||||
} | } | ||||
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); | RPCTypeCheck(request.params, {UniValue::VNUM}); | ||||
int nBlocks = request.params[0].get_int(); | int nBlocks = request.params[0].get_int(); | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
int answerFound; | int answerFound; | ||||
double priority = mempool.estimateSmartPriority(nBlocks, &answerFound); | double priority = mempool.estimateSmartPriority(nBlocks, &answerFound); | ||||
result.push_back(Pair("priority", priority)); | result.push_back(Pair("priority", priority)); | ||||
result.push_back(Pair("blocks", answerFound)); | result.push_back(Pair("blocks", answerFound)); | ||||
Show All 27 Lines |