|
|
@ -3641,22 +3641,28 @@ UniValue z_getwitnesscachestats(const UniValue& params, bool fHelp, const CPubKe |
|
|
|
if (!EnsureWalletIsAvailable(fHelp)) |
|
|
|
return NullUniValue; |
|
|
|
|
|
|
|
if (fHelp || params.size() < 1 || params.size() > 2) |
|
|
|
if (fHelp || params.size() > 0 ) |
|
|
|
throw runtime_error( |
|
|
|
"z_getwitnesscachestats\n" |
|
|
|
"\nReturns statistics about the witness cache for zaddrs\n" |
|
|
|
"\nResult:\n" |
|
|
|
"\njson\n" |
|
|
|
"\nExamples:\n" |
|
|
|
+ HelpExampleCli("z_getwitnesscachestats", "456") |
|
|
|
+ HelpExampleRpc("z_getwitnesscachestats", "456") |
|
|
|
+ HelpExampleCli("z_getwitnesscachestats","") |
|
|
|
+ HelpExampleRpc("z_getwitnesscachestats","") |
|
|
|
); |
|
|
|
|
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
uint32_t nMinDepth = 1; |
|
|
|
uint64_t total_witnesses = 0; |
|
|
|
uint64_t total_zutxos = 0; |
|
|
|
std::vector<uint256> nullifiers; |
|
|
|
|
|
|
|
for (auto& wtx : pwalletMain->mapWallet) { |
|
|
|
// add all nullifiers in this tx to our list
|
|
|
|
for (uint32_t i = 0; i < wtx.second.vShieldedSpend.size(); i++) { |
|
|
|
nullifiers.emplace_back(wtx.second.vShieldedSpend[i].nullifier); |
|
|
|
} |
|
|
|
if (wtx.second.GetDepthInMainChain() >= nMinDepth) { |
|
|
|
total_zutxos += wtx.second.mapSaplingNoteData.size(); |
|
|
|
for (mapSaplingNoteData_t::value_type& item : wtx.second.mapSaplingNoteData) { |
|
|
@ -3667,6 +3673,7 @@ UniValue z_getwitnesscachestats(const UniValue& params, bool fHelp, const CPubKe |
|
|
|
} |
|
|
|
UniValue ret(UniValue::VOBJ); |
|
|
|
ret.pushKV("total_witnesses", total_witnesses); |
|
|
|
ret.pushKV("total_nullifiers", nullifiers.size()); |
|
|
|
ret.pushKV("total_zutxos", total_zutxos); |
|
|
|
ret.pushKV("witnesses_cache_size", pwalletMain->nWitnessCacheSize); |
|
|
|
ret.pushKV("max_witnesses_cache_size", (int) WITNESS_CACHE_SIZE); |
|
|
|