Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,291 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
"'hash_serialized' (the legacy algorithm), 'muhash', 'none'."}, | "'hash_serialized' (the legacy algorithm), 'muhash', 'none'."}, | ||||
{"hash_or_height", | {"hash_or_height", | ||||
RPCArg::Type::NUM, | RPCArg::Type::NUM, | ||||
RPCArg::Optional::OMITTED, | RPCArg::Optional::OMITTED, | ||||
"The block hash or height of the target height (only available " | "The block hash or height of the target height (only available " | ||||
"with coinstatsindex).", | "with coinstatsindex).", | ||||
"", | "", | ||||
{"", "string or numeric"}}, | {"", "string or numeric"}}, | ||||
{"use_index", RPCArg::Type::BOOL, /* default */ "true", | |||||
"Use coinstatsindex, if available."}, | |||||
}, | }, | ||||
RPCResult{ | RPCResult{ | ||||
RPCResult::Type::OBJ, | RPCResult::Type::OBJ, | ||||
"", | "", | ||||
"", | "", | ||||
{ | { | ||||
{RPCResult::Type::NUM, "height", | {RPCResult::Type::NUM, "height", | ||||
"The current block height (index)"}, | "The current block height (index)"}, | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
CBlockIndex *pindex{nullptr}; | CBlockIndex *pindex{nullptr}; | ||||
const CoinStatsHashType hash_type{ | const CoinStatsHashType hash_type{ | ||||
request.params[0].isNull() | request.params[0].isNull() | ||||
? CoinStatsHashType::HASH_SERIALIZED | ? CoinStatsHashType::HASH_SERIALIZED | ||||
: ParseHashType(request.params[0].get_str())}; | : ParseHashType(request.params[0].get_str())}; | ||||
CCoinsStats stats{hash_type}; | CCoinsStats stats{hash_type}; | ||||
stats.index_requested = | |||||
request.params[2].isNull() || request.params[2].get_bool(); | |||||
NodeContext &node = EnsureAnyNodeContext(request.context); | NodeContext &node = EnsureAnyNodeContext(request.context); | ||||
ChainstateManager &chainman = EnsureChainman(node); | ChainstateManager &chainman = EnsureChainman(node); | ||||
CChainState &active_chainstate = chainman.ActiveChainstate(); | CChainState &active_chainstate = chainman.ActiveChainstate(); | ||||
active_chainstate.ForceFlushStateToDisk(); | active_chainstate.ForceFlushStateToDisk(); | ||||
CCoinsView *coins_view; | CCoinsView *coins_view; | ||||
BlockManager *blockman; | BlockManager *blockman; | ||||
Show All 23 Lines | return RPCHelpMan{ | ||||
if (hash_type == CoinStatsHashType::HASH_SERIALIZED) { | if (hash_type == CoinStatsHashType::HASH_SERIALIZED) { | ||||
ret.pushKV("hash_serialized", | ret.pushKV("hash_serialized", | ||||
stats.hashSerialized.GetHex()); | stats.hashSerialized.GetHex()); | ||||
} | } | ||||
if (hash_type == CoinStatsHashType::MUHASH) { | if (hash_type == CoinStatsHashType::MUHASH) { | ||||
ret.pushKV("muhash", stats.hashSerialized.GetHex()); | ret.pushKV("muhash", stats.hashSerialized.GetHex()); | ||||
} | } | ||||
ret.pushKV("total_amount", stats.nTotalAmount); | ret.pushKV("total_amount", stats.nTotalAmount); | ||||
if (!stats.from_index) { | if (!stats.index_used) { | ||||
ret.pushKV("transactions", | ret.pushKV("transactions", | ||||
static_cast<int64_t>(stats.nTransactions)); | static_cast<int64_t>(stats.nTransactions)); | ||||
ret.pushKV("disk_size", stats.nDiskSize); | ret.pushKV("disk_size", stats.nDiskSize); | ||||
} else { | } else { | ||||
ret.pushKV("total_unspendable_amount", | ret.pushKV("total_unspendable_amount", | ||||
stats.total_unspendable_amount); | stats.total_unspendable_amount); | ||||
CCoinsStats prev_stats{hash_type}; | CCoinsStats prev_stats{hash_type}; | ||||
▲ Show 20 Lines • Show All 1,893 Lines • Show Last 20 Lines |