From 024f6ff43d533640857958f36a7b6e609b7706b7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 27 Aug 2019 05:58:49 -0700 Subject: [PATCH] More organic stats --- src/rpc/blockchain.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 122c6ba25..8703d6a95 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1937,6 +1937,8 @@ inline CBlockIndex* LookupBlockIndex(const uint256& hash) return it == mapBlockIndex.end() ? nullptr : it->second; } +#define ORG(X) (X - blockcount - nNotarizationsDiff) + UniValue getchaintxstats(const UniValue& params, bool fHelp) { if (fHelp || params.size() > 2) @@ -2082,13 +2084,17 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) ret.pushKV("shielded_only", shielded); // Organic tx stats = Raw - Coinbase - DPoW - UniValue organic(UniValue::VOBJ); - organic.pushKV("shielded_txrate", ((double)nShieldedTxDiff - blockcount - nNotarizationsDiff ) / nTimeDiff); - organic.pushKV("fully_shielded_txrate", ((double)nFullyShieldedTxDiff - blockcount - nNotarizationsDiff ) / nTimeDiff); - organic.pushKV("shielding_txrate", ((double)nShieldingTxDiff - blockcount - nNotarizationsDiff ) / nTimeDiff); - organic.pushKV("deshielding_txrate", ((double)nDeshieldingTxDiff - blockcount - nNotarizationsDiff ) / nTimeDiff); - if (nTxDiff > 0) { + UniValue organic(UniValue::VOBJ); + organic.pushKV("shielded_txrate", ((double)nShieldedTxDiff - blockcount - nNotarizationsDiff ) / nTimeDiff); + organic.pushKV("fully_shielded_txrate", ((double)nFullyShieldedTxDiff - blockcount - nNotarizationsDiff ) / nTimeDiff); + organic.pushKV("shielding_txrate", ((double)nShieldingTxDiff - blockcount - nNotarizationsDiff ) / nTimeDiff); + organic.pushKV("deshielding_txrate", ((double)nDeshieldingTxDiff - blockcount - nNotarizationsDiff ) / nTimeDiff); + + ret.pushKV("shielded_tx_percent", ((double)ORG(nShieldedTxDiff)) / nTxDiff); + ret.pushKV("fully_shielded_tx_percent", ((double)ORG(nFullyShieldedTxDiff)) / nTxDiff); + ret.pushKV("shielding_tx_percent", ((double)ORG(nShieldingTxDiff)) / nTxDiff); + ret.pushKV("deshielding_tx_percent", ((double)ORG(nDeshieldingTxDiff)) / nTxDiff); ret.pushKV("organic", organic); } }