Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,269 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
::ChainstateActive().ForceFlushStateToDisk(); | ::ChainstateActive().ForceFlushStateToDisk(); | ||||
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())}; | ||||
CCoinsView *coins_view = | CCoinsView *coins_view = | ||||
WITH_LOCK(cs_main, return &ChainstateActive().CoinsDB()); | WITH_LOCK(::cs_main, return &::ChainstateActive().CoinsDB()); | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
if (GetUTXOStats(coins_view, stats, hash_type, | if (GetUTXOStats(coins_view, | ||||
node.rpc_interruption_point)) { | WITH_LOCK(::cs_main, | ||||
return std::ref(g_chainman.m_blockman)), | |||||
stats, hash_type, node.rpc_interruption_point)) { | |||||
ret.pushKV("height", int64_t(stats.nHeight)); | ret.pushKV("height", int64_t(stats.nHeight)); | ||||
ret.pushKV("bestblock", stats.hashBlock.GetHex()); | ret.pushKV("bestblock", stats.hashBlock.GetHex()); | ||||
ret.pushKV("transactions", int64_t(stats.nTransactions)); | ret.pushKV("transactions", int64_t(stats.nTransactions)); | ||||
ret.pushKV("txouts", int64_t(stats.nTransactionOutputs)); | ret.pushKV("txouts", int64_t(stats.nTransactionOutputs)); | ||||
ret.pushKV("bogosize", int64_t(stats.nBogoSize)); | ret.pushKV("bogosize", int64_t(stats.nBogoSize)); | ||||
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()); | ||||
▲ Show 20 Lines • Show All 1,749 Lines • ▼ Show 20 Lines | CBlockIndex *tip; | ||||
// | // | ||||
// 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); | ||||
chainstate.ForceFlushStateToDisk(); | chainstate.ForceFlushStateToDisk(); | ||||
if (!GetUTXOStats(&chainstate.CoinsDB(), stats, CoinStatsHashType::NONE, | if (!GetUTXOStats(&chainstate.CoinsDB(), chainstate.m_blockman, stats, | ||||
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 = | pcursor = | ||||
std::unique_ptr<CCoinsViewCursor>(chainstate.CoinsDB().Cursor()); | std::unique_ptr<CCoinsViewCursor>(chainstate.CoinsDB().Cursor()); | ||||
tip = g_chainman.m_blockman.LookupBlockIndex(stats.hashBlock); | tip = g_chainman.m_blockman.LookupBlockIndex(stats.hashBlock); | ||||
CHECK_NONFATAL(tip); | CHECK_NONFATAL(tip); | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |