Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,481 Lines • ▼ Show 20 Lines | for (const CBlockIndex *block : setTips) { | ||||
res.push_back(obj); | res.push_back(obj); | ||||
} | } | ||||
return res; | return res; | ||||
} | } | ||||
UniValue MempoolInfoToJSON(const CTxMemPool &pool) { | UniValue MempoolInfoToJSON(const CTxMemPool &pool) { | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
ret.pushKV("loaded", pool.IsLoaded()); | |||||
ret.pushKV("size", (int64_t)pool.size()); | ret.pushKV("size", (int64_t)pool.size()); | ||||
ret.pushKV("bytes", (int64_t)pool.GetTotalTxSize()); | ret.pushKV("bytes", (int64_t)pool.GetTotalTxSize()); | ||||
ret.pushKV("usage", (int64_t)pool.DynamicMemoryUsage()); | ret.pushKV("usage", (int64_t)pool.DynamicMemoryUsage()); | ||||
size_t maxmempool = | size_t maxmempool = | ||||
gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; | gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; | ||||
ret.pushKV("maxmempool", (int64_t)maxmempool); | ret.pushKV("maxmempool", (int64_t)maxmempool); | ||||
ret.pushKV( | ret.pushKV( | ||||
"mempoolminfee", | "mempoolminfee", | ||||
ValueFromAmount(std::max(pool.GetMinFee(maxmempool), ::minRelayTxFee) | ValueFromAmount(std::max(pool.GetMinFee(maxmempool), ::minRelayTxFee) | ||||
.GetFeePerK())); | .GetFeePerK())); | ||||
ret.pushKV("minrelaytxfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())); | ret.pushKV("minrelaytxfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())); | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue getmempoolinfo(const Config &config, | static UniValue getmempoolinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 0) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"getmempoolinfo\n" | "getmempoolinfo\n" | ||||
"\nReturns details on the active state of the TX memory pool.\n" | "\nReturns details on the active state of the TX memory pool.\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"loaded\": true|false (boolean) True if the mempool is " | |||||
"fully loaded\n" | |||||
" \"size\": xxxxx, (numeric) Current tx count\n" | " \"size\": xxxxx, (numeric) Current tx count\n" | ||||
" \"bytes\": xxxxx, (numeric) Transaction size.\n" | " \"bytes\": xxxxx, (numeric) Transaction size.\n" | ||||
" \"usage\": xxxxx, (numeric) Total memory usage for " | " \"usage\": xxxxx, (numeric) Total memory usage for " | ||||
"the mempool\n" | "the mempool\n" | ||||
" \"maxmempool\": xxxxx, (numeric) Maximum memory usage " | " \"maxmempool\": xxxxx, (numeric) Maximum memory usage " | ||||
"for the mempool\n" | "for the mempool\n" | ||||
" \"mempoolminfee\": xxxxx (numeric) Minimum fee rate in " + | " \"mempoolminfee\": xxxxx (numeric) Minimum fee rate in " + | ||||
CURRENCY_UNIT + | CURRENCY_UNIT + | ||||
▲ Show 20 Lines • Show All 671 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error("savemempool\n" | throw std::runtime_error("savemempool\n" | ||||
"\nDumps the mempool to disk. It will fail " | "\nDumps the mempool to disk. It will fail " | ||||
"until the previous dump is fully loaded.\n" | "until the previous dump is fully loaded.\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("savemempool", "") + | HelpExampleCli("savemempool", "") + | ||||
HelpExampleRpc("savemempool", "")); | HelpExampleRpc("savemempool", "")); | ||||
} | } | ||||
if (!g_is_mempool_loaded) { | if (!::g_mempool.IsLoaded()) { | ||||
throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet"); | throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet"); | ||||
} | } | ||||
if (!DumpMempool()) { | if (!DumpMempool(::g_mempool)) { | ||||
throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk"); | throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk"); | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
// clang-format off | // clang-format off | ||||
static const ContextFreeRPCCommand commands[] = { | static const ContextFreeRPCCommand commands[] = { | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |