Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 517 Lines • ▼ Show 20 Lines | return { | ||||
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", | {RPCResult{RPCResult::Type::STR_HEX, "transactionid", | ||||
"parent transaction id"}}}, | "parent transaction id"}}}, | ||||
RPCResult{ | RPCResult{ | ||||
RPCResult::Type::ARR, | RPCResult::Type::ARR, | ||||
"spentby", | "spentby", | ||||
"unconfirmed transactions spending outputs from this transaction", | "unconfirmed transactions spending outputs from this transaction", | ||||
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", | {RPCResult{RPCResult::Type::STR_HEX, "transactionid", | ||||
"child transaction id"}}}, | "child transaction id"}}}, | ||||
RPCResult{RPCResult::Type::BOOL, "unbroadcast", | |||||
"Whether this transaction is currently unbroadcast (initial " | |||||
"broadcast not yet confirmed)"}, | |||||
}; | }; | ||||
} | } | ||||
static void entryToJSON(const CTxMemPool &pool, UniValue &info, | static void entryToJSON(const CTxMemPool &pool, UniValue &info, | ||||
const CTxMemPoolEntry &e) | const CTxMemPoolEntry &e) | ||||
EXCLUSIVE_LOCKS_REQUIRED(pool.cs) { | EXCLUSIVE_LOCKS_REQUIRED(pool.cs) { | ||||
AssertLockHeld(pool.cs); | AssertLockHeld(pool.cs); | ||||
Show All 33 Lines | static void entryToJSON(const CTxMemPool &pool, UniValue &info, | ||||
UniValue spent(UniValue::VARR); | UniValue spent(UniValue::VARR); | ||||
const CTxMemPool::txiter &it = pool.mapTx.find(tx.GetId()); | const CTxMemPool::txiter &it = pool.mapTx.find(tx.GetId()); | ||||
const CTxMemPool::setEntries &setChildren = pool.GetMemPoolChildren(it); | const CTxMemPool::setEntries &setChildren = pool.GetMemPoolChildren(it); | ||||
for (CTxMemPool::txiter childiter : setChildren) { | for (CTxMemPool::txiter childiter : setChildren) { | ||||
spent.push_back(childiter->GetTx().GetId().ToString()); | spent.push_back(childiter->GetTx().GetId().ToString()); | ||||
} | } | ||||
info.pushKV("spentby", spent); | info.pushKV("spentby", spent); | ||||
info.pushKV("unbroadcast", pool.IsUnbroadcastTx(tx.GetId())); | |||||
} | } | ||||
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose) { | UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose) { | ||||
if (verbose) { | if (verbose) { | ||||
LOCK(pool.cs); | LOCK(pool.cs); | ||||
UniValue o(UniValue::VOBJ); | UniValue o(UniValue::VOBJ); | ||||
for (const CTxMemPoolEntry &e : pool.mapTx) { | for (const CTxMemPoolEntry &e : pool.mapTx) { | ||||
const uint256 &txid = e.GetTx().GetId(); | const uint256 &txid = e.GetTx().GetId(); | ||||
▲ Show 20 Lines • Show All 1,137 Lines • ▼ Show 20 Lines | UniValue MempoolInfoToJSON(const CTxMemPool &pool) { | ||||
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())); | ||||
ret.pushKV("unbroadcastcount", uint64_t{pool.GetUnbroadcastTxs().size()}); | |||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue getmempoolinfo(const Config &config, | static UniValue getmempoolinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getmempoolinfo", | "getmempoolinfo", | ||||
"Returns details on the active state of the TX memory pool.\n", | "Returns details on the active state of the TX memory pool.\n", | ||||
Show All 12 Lines | RPCHelpMan{ | ||||
{RPCResult::Type::NUM, "maxmempool", | {RPCResult::Type::NUM, "maxmempool", | ||||
"Maximum memory usage for the mempool"}, | "Maximum memory usage for the mempool"}, | ||||
{RPCResult::Type::STR_AMOUNT, "mempoolminfee", | {RPCResult::Type::STR_AMOUNT, "mempoolminfee", | ||||
"Minimum fee rate in " + CURRENCY_UNIT + | "Minimum fee rate in " + CURRENCY_UNIT + | ||||
"/kB for tx to be accepted. Is the maximum of " | "/kB for tx to be accepted. Is the maximum of " | ||||
"minrelaytxfee and minimum mempool fee"}, | "minrelaytxfee and minimum mempool fee"}, | ||||
{RPCResult::Type::STR_AMOUNT, "minrelaytxfee", | {RPCResult::Type::STR_AMOUNT, "minrelaytxfee", | ||||
"Current minimum relay fee for transactions"}, | "Current minimum relay fee for transactions"}, | ||||
{RPCResult::Type::NUM, "unbroadcastcount", | |||||
"Current number of transactions that haven't passed initial " | |||||
"broadcast yet"}, | |||||
}}, | }}, | ||||
RPCExamples{HelpExampleCli("getmempoolinfo", "") + | RPCExamples{HelpExampleCli("getmempoolinfo", "") + | ||||
HelpExampleRpc("getmempoolinfo", "")}, | HelpExampleRpc("getmempoolinfo", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
return MempoolInfoToJSON(EnsureMemPool(request.context)); | return MempoolInfoToJSON(EnsureMemPool(request.context)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,215 Lines • Show Last 20 Lines |