Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,177 Lines • ▼ Show 20 Lines | static UniValue gettxoutsetinfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"gettxoutsetinfo", | "gettxoutsetinfo", | ||||
"Returns statistics about the unspent transaction output set.\n" | "Returns statistics about the unspent transaction output set.\n" | ||||
"Note this call may take some time.\n", | "Note this call may take some time.\n", | ||||
{ | { | ||||
{"hash_type", RPCArg::Type::STR, /* default */ "hash_serialized", | {"hash_type", RPCArg::Type::STR, /* default */ "hash_serialized", | ||||
"Which UTXO set hash should be calculated. Options: " | "Which UTXO set hash should be calculated. Options: " | ||||
"'hash_serialized' (the legacy algorithm)."}, | "'hash_serialized' (the legacy algorithm), 'none'."}, | ||||
}, | }, | ||||
RPCResult{RPCResult::Type::OBJ, | RPCResult{RPCResult::Type::OBJ, | ||||
"", | "", | ||||
"", | "", | ||||
{ | { | ||||
{RPCResult::Type::NUM, "height", | {RPCResult::Type::NUM, "height", | ||||
"The current block height (index)"}, | "The current block height (index)"}, | ||||
{RPCResult::Type::STR_HEX, "bestblock", | {RPCResult::Type::STR_HEX, "bestblock", | ||||
▲ Show 20 Lines • Show All 1,697 Lines • ▼ Show 20 Lines | NodeContext &node = EnsureNodeContext(request.context); | ||||
// See discussion here: | // See discussion here: | ||||
// https://github.com/bitcoin/bitcoin/pull/15606#discussion_r274479369 | // https://github.com/bitcoin/bitcoin/pull/15606#discussion_r274479369 | ||||
// | // | ||||
LOCK(::cs_main); | LOCK(::cs_main); | ||||
::ChainstateActive().ForceFlushStateToDisk(); | ::ChainstateActive().ForceFlushStateToDisk(); | ||||
if (!GetUTXOStats(&::ChainstateActive().CoinsDB(), stats, | if (!GetUTXOStats(&::ChainstateActive().CoinsDB(), stats, | ||||
CoinStatsHashType::HASH_SERIALIZED, | CoinStatsHashType::NONE, | ||||
node.rpc_interruption_point)) { | node.rpc_interruption_point)) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); | throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); | ||||
} | } | ||||
pcursor = std::unique_ptr<CCoinsViewCursor>( | pcursor = std::unique_ptr<CCoinsViewCursor>( | ||||
::ChainstateActive().CoinsDB().Cursor()); | ::ChainstateActive().CoinsDB().Cursor()); | ||||
tip = LookupBlockIndex(stats.hashBlock); | tip = LookupBlockIndex(stats.hashBlock); | ||||
CHECK_NONFATAL(tip); | CHECK_NONFATAL(tip); | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |