Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 851 Lines • ▼ Show 20 Lines | |||||
struct CCoinsStats { | struct CCoinsStats { | ||||
int nHeight; | int nHeight; | ||||
uint256 hashBlock; | uint256 hashBlock; | ||||
uint64_t nTransactions; | uint64_t nTransactions; | ||||
uint64_t nTransactionOutputs; | uint64_t nTransactionOutputs; | ||||
uint64_t nBogoSize; | uint64_t nBogoSize; | ||||
uint256 hashSerialized; | uint256 hashSerialized; | ||||
uint256 hashCommitment; | |||||
uint64_t nDiskSize; | uint64_t nDiskSize; | ||||
Amount nTotalAmount; | Amount nTotalAmount; | ||||
CCoinsStats() | CCoinsStats() | ||||
: nHeight(0), nTransactions(0), nTransactionOutputs(0), nBogoSize(0), | : nHeight(0), nTransactions(0), nTransactionOutputs(0), nBogoSize(0), | ||||
nDiskSize(0), nTotalAmount(0) {} | nDiskSize(0), nTotalAmount(0) {} | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | while (pcursor->Valid()) { | ||||
} | } | ||||
pcursor->Next(); | pcursor->Next(); | ||||
} | } | ||||
if (!outputs.empty()) { | if (!outputs.empty()) { | ||||
ApplyStats(stats, ss, prevkey, outputs); | ApplyStats(stats, ss, prevkey, outputs); | ||||
} | } | ||||
stats.hashSerialized = ss.GetHash(); | stats.hashSerialized = ss.GetHash(); | ||||
stats.nDiskSize = view->EstimateSize(); | stats.nDiskSize = view->EstimateSize(); | ||||
CUtxoCommit *commitment = view->GetCommitment(); | |||||
stats.hashCommitment = | |||||
(commitment == nullptr ? uint256() : commitment->GetHash()); | |||||
return true; | return true; | ||||
} | } | ||||
UniValue pruneblockchain(const Config &config, const JSONRPCRequest &request) { | UniValue pruneblockchain(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"pruneblockchain\n" | "pruneblockchain\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | UniValue gettxoutsetinfo(const Config &config, const JSONRPCRequest &request) { | ||||
FlushStateToDisk(); | FlushStateToDisk(); | ||||
if (GetUTXOStats(pcoinsTip, stats)) { | if (GetUTXOStats(pcoinsTip, stats)) { | ||||
ret.push_back(Pair("height", int64_t(stats.nHeight))); | ret.push_back(Pair("height", int64_t(stats.nHeight))); | ||||
ret.push_back(Pair("bestblock", stats.hashBlock.GetHex())); | ret.push_back(Pair("bestblock", stats.hashBlock.GetHex())); | ||||
ret.push_back(Pair("transactions", int64_t(stats.nTransactions))); | ret.push_back(Pair("transactions", int64_t(stats.nTransactions))); | ||||
ret.push_back(Pair("txouts", int64_t(stats.nTransactionOutputs))); | ret.push_back(Pair("txouts", int64_t(stats.nTransactionOutputs))); | ||||
ret.push_back(Pair("bogosize", int64_t(stats.nBogoSize))); | ret.push_back(Pair("bogosize", int64_t(stats.nBogoSize))); | ||||
ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex())); | ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex())); | ||||
ret.push_back(Pair("hash_commitment", stats.hashCommitment.GetHex())); | |||||
ret.push_back(Pair("disk_size", stats.nDiskSize)); | ret.push_back(Pair("disk_size", stats.nDiskSize)); | ||||
ret.push_back( | ret.push_back( | ||||
Pair("total_amount", ValueFromAmount(stats.nTotalAmount))); | Pair("total_amount", ValueFromAmount(stats.nTotalAmount))); | ||||
} else { | } else { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); | throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to read UTXO set"); | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 730 Lines • Show Last 20 Lines |