From 5e26d8ec4cf7ef763c80300dbc6121d910cc6bac Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 27 Aug 2019 04:42:24 -0700 Subject: [PATCH 1/9] WIP organic txstats and add some missing stats --- src/rpc/blockchain.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index ecc5cd848..122c6ba25 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2037,6 +2037,8 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) if (fZindex) { ret.pushKV("notarization_txrate", ((double)nNotarizationsDiff) / nTimeDiff); ret.pushKV("shielded_txrate", ((double)nShieldedTxDiff) / nTimeDiff); + ret.pushKV("shielding_txrate", ((double)nShieldingTxDiff) / nTimeDiff); + ret.pushKV("deshielding_txrate", ((double)nDeshieldingTxDiff) / nTimeDiff); ret.pushKV("fully_shielded_txrate", ((double)nFullyShieldedTxDiff) / nTimeDiff); ret.pushKV("paymentrate", ((double)nPaymentsDiff) / nTimeDiff); ret.pushKV("shielded_paymentrate", ((double)nShieldedPaymentsDiff) / nTimeDiff); @@ -2078,6 +2080,17 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) } if(nShieldedTxDiff+nShieldedPaymentsDiff > 0) 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) { + ret.pushKV("organic", organic); + } } } From 024f6ff43d533640857958f36a7b6e609b7706b7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 27 Aug 2019 05:58:49 -0700 Subject: [PATCH 2/9] 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); } } From 715dc7cb363d6c17ffafb533837fe154084e6ec3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 27 Aug 2019 06:23:02 -0700 Subject: [PATCH 3/9] These organic stats actually make sense --- src/rpc/blockchain.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 8703d6a95..b6285d96f 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -2086,16 +2087,14 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) // Organic tx stats = Raw - Coinbase - DPoW 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); + + organic.pushKV("shielded_tx_percent", ((double)nShieldedTxDiff) / ORG(nTxDiff)); + organic.pushKV("fully_shielded_tx_percent", ((double)nFullyShieldedTxDiff) / ORG(nTxDiff)); + organic.pushKV("shielding_tx_percent", ((double)nShieldingTxDiff) / ORG(nTxDiff)); + organic.pushKV("deshielding_tx_percent", ((double)nDeshieldingTxDiff) / ORG(nTxDiff)); + + organic.pushKV("txcount", (int) ORG(nTxDiff)); + organic.pushKV("organic", organic); } } } From c1dd6e5b961969c7656a88d3ed442f11a06b1f97 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 4 Sep 2019 14:04:49 -0700 Subject: [PATCH 4/9] Add organic payment percents, organic paymentrate and txrate and organic payment count --- src/rpc/blockchain.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index b6285d96f..a7cca202d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2003,15 +2003,15 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) ret.pushKV("txcount", (int64_t)pindex->nChainTx); if (fZindex) { - ret.pushKV("notarizations", (int64_t)pindex->nChainNotarizations); - ret.pushKV("shielded_txcount", (int64_t)pindex->nChainShieldedTx); + ret.pushKV("notarizations", (int64_t)pindex->nChainNotarizations); + ret.pushKV("shielded_txcount", (int64_t)pindex->nChainShieldedTx); ret.pushKV("fully_shielded_txcount", (int64_t)pindex->nChainFullyShieldedTx); - ret.pushKV("deshielding_txcount", (int64_t)pindex->nChainDeshieldingTx); - ret.pushKV("shielding_txcount", (int64_t)pindex->nChainShieldingTx); - ret.pushKV("shielded_payments", (int64_t)pindex->nChainShieldedPayments); - ret.pushKV("fully_shielded_payments", (int64_t)pindex->nChainFullyShieldedPayments); - ret.pushKV("deshielding_payments", (int64_t)pindex->nChainDeshieldingPayments); - ret.pushKV("shielding_payments", (int64_t)pindex->nChainShieldingPayments); + ret.pushKV("deshielding_txcount", (int64_t)pindex->nChainDeshieldingTx); + ret.pushKV("shielding_txcount", (int64_t)pindex->nChainShieldingTx); + ret.pushKV("shielded_payments", (int64_t)pindex->nChainShieldedPayments); + ret.pushKV("fully_shielded_payments",(int64_t)pindex->nChainFullyShieldedPayments); + ret.pushKV("deshielding_payments", (int64_t)pindex->nChainDeshieldingPayments); + ret.pushKV("shielding_payments", (int64_t)pindex->nChainShieldingPayments); } ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex()); @@ -2088,12 +2088,18 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) if (nTxDiff > 0) { UniValue organic(UniValue::VOBJ); - organic.pushKV("shielded_tx_percent", ((double)nShieldedTxDiff) / ORG(nTxDiff)); - organic.pushKV("fully_shielded_tx_percent", ((double)nFullyShieldedTxDiff) / ORG(nTxDiff)); - organic.pushKV("shielding_tx_percent", ((double)nShieldingTxDiff) / ORG(nTxDiff)); - organic.pushKV("deshielding_tx_percent", ((double)nDeshieldingTxDiff) / ORG(nTxDiff)); - + organic.pushKV("shielded_tx_percent", ((double)nShieldedTxDiff) / ORG(nTxDiff)); + organic.pushKV("fully_shielded_tx_percent", ((double)nFullyShieldedTxDiff) / ORG(nTxDiff)); + organic.pushKV("shielding_tx_percent", ((double)nShieldingTxDiff) / ORG(nTxDiff)); + organic.pushKV("deshielding_tx_percent", ((double)nDeshieldingTxDiff) / ORG(nTxDiff)); + organic.pushKV("shielded_payments_percent", ((double)nShieldedPaymentsDiff) / ORG(nPaymentsDiff)); + organic.pushKV("fully_shielded_payments_percent", ((double)nFullyShieldedPaymentsDiff) / ORG(nPaymentsDiff)); + organic.pushKV("shielding_payments_percent", ((double)nShieldingPaymentsDiff) / ORG(nPaymentsDiff)); + organic.pushKV("deshielding_payments_percent", ((double)nDeshieldingPaymentsDiff) / ORG(nPaymentsDiff)); + organic.pushKV("paymentrate", ((double)ORG(nPaymentsDiff)) / nTimeDiff); + organic.pushKV("txrate", ((double)ORG(nTxDiff)) / nTimeDiff); organic.pushKV("txcount", (int) ORG(nTxDiff)); + organic.pushKV("payments", (int) ORG(nPaymentsDiff)); organic.pushKV("organic", organic); } } From 4b970170775168054cc913f12bcd3d5e1995b2f5 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 5 Sep 2019 08:19:04 +0200 Subject: [PATCH 5/9] Correctly return organic json --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index a7cca202d..b8a0e7c23 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2100,7 +2100,7 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) organic.pushKV("txrate", ((double)ORG(nTxDiff)) / nTimeDiff); organic.pushKV("txcount", (int) ORG(nTxDiff)); organic.pushKV("payments", (int) ORG(nPaymentsDiff)); - organic.pushKV("organic", organic); + ret.pushKV("organic", organic); } } } From 22c2aa8fda545113c4fb6be5813594f4896601f9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 5 Sep 2019 08:49:35 -0400 Subject: [PATCH 6/9] shielded is a better name for this key --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index a7cca202d..105d8f6f5 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2082,7 +2082,7 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) shielded.pushKV("deshielding_payments_percent", ((double)nDeshieldingPaymentsDiff) / nShieldedPaymentsDiff ); } if(nShieldedTxDiff+nShieldedPaymentsDiff > 0) - ret.pushKV("shielded_only", shielded); + ret.pushKV("shielded", shielded); // Organic tx stats = Raw - Coinbase - DPoW if (nTxDiff > 0) { From 799f6d757b484ed6a12cc315a0e848fc35981b31 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 5 Sep 2019 08:56:47 -0400 Subject: [PATCH 7/9] Add some docs for getchaintxstats new features --- src/rpc/blockchain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index d1ce1188c..055ba5566 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1946,15 +1946,18 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) throw runtime_error( "getchaintxstats\n" "\nCompute statistics about the total number and rate of transactions in the chain.\n" + "\nThis RPC will return extra data about shielded transactions, payments and notarizations if the zindex is enabled .\n" "\nArguments:\n" "1. nblocks (numeric, optional) Number of blocks in averaging window.\n" "2. blockhash (string, optional) The hash of the block which ends the window.\n" "\nResult:\n" "{\n" " \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n" + " \"notarizations\": xxxxx, (optional, numeric) The number of notarizations in the chain.\n" " \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n" " \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n" " \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n" + " \"window_notarizations\": xxxxx, (optional, numeric) Number of notarization transactions in window.\n" " \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n" " \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n" " \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n" From 0989dbdc1d4feecf0f51c620016aee7ef4caa3a9 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 5 Sep 2019 06:29:15 -0700 Subject: [PATCH 8/9] Lots mo docs --- src/rpc/blockchain.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 055ba5566..81a553fa6 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1953,14 +1953,26 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) "\nResult:\n" "{\n" " \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n" - " \"notarizations\": xxxxx, (optional, numeric) The number of notarizations in the chain.\n" + " \"notarizations\": xxxxx, (numeric) The number of notarizations in the chain. Only returned if zindex=1\n" " \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n" " \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n" + " \"window_final_block_height\": \"...\", (numeric) The height of the final block in the window.\n" " \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n" - " \"window_notarizations\": xxxxx, (optional, numeric) Number of notarization transactions in window.\n" + " \"window_notarizations\": xxxxx, (numeric) Number of notarization transactions in window. Only returned if zindex=1\n" " \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n" + " \"window_payments\": xxxxx, (numeric) The number of payments in the window. Only returned if \"window_block_count\" is > 0 and zindex=1.\n" " \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n" " \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n" + " \"notarization_txrate\": x.xx, (numeric) The average rate of notarization transactions per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" + " \"paymentrate\": x.xx, (numeric) The average rate of payments per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" + " \"shielded_txcount\": xxxxx, (numeric) The total number of shielded transactions in the chain up to that point. Only returned if zindex=1\n" + " \"fully_shielded_txcount\": xxxxx, (numeric) The total number of fully shielded transactions (z2z) in the chain up to that point. Only returned if zindex=1\n" + " \"shielding_txcount\": xxxxx, (numeric) The total number of shielding transactions (t=>z) in the chain up to that point. Only returned if zindex=1\n" + " \"deshielding_txcount\": xxxxx, (numeric) The total number of deshielding transactions (z=>t) in the chain up to that point. Only returned if zindex=1\n" + " \"shielded_payments\": xxxxx, (numeric) The total number of shielded payments in the chain up to that point. Only returned if zindex=1\n" + " \"fully_shielded_payments\": xxxxx, (numeric) The total number of fully shielded payments (z2z) in the chain up to that point. Only returned if zindex=1\n" + " \"shielding_payments\": xxxxx, (numeric) The total number of shielding payments (t=>z) in the chain up to that point. Only returned if zindex=1\n" + " \"deshielding_payments\": xxxxx, (numeric) The total number of deshielding payments (z=>t) in the chain up to that point. Only returned if zindex=1\n" "}\n" "\nExamples:\n" + HelpExampleCli("getchaintxstats", "") From 509bc51c685ee360048ff3d438e884d1f3e34e04 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 5 Sep 2019 08:12:01 -0700 Subject: [PATCH 9/9] Docs about ztxrates --- src/rpc/blockchain.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 81a553fa6..b61dabe3d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1963,8 +1963,13 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp) " \"window_payments\": xxxxx, (numeric) The number of payments in the window. Only returned if \"window_block_count\" is > 0 and zindex=1.\n" " \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n" " \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n" + " \"shielded_txrate\": x.xx, (numeric) The average rate of shielded transactions per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" + " \"shielding_txrate\": x.xx, (numeric) The average rate of shielding transactions per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" + " \"deshielding_txrate\": x.xx, (numeric) The average rate of deshielding transactions per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" + " \"fully_shielded_txrate\": x.xx, (numeric) The average rate of fully shielded transactions per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" " \"notarization_txrate\": x.xx, (numeric) The average rate of notarization transactions per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" " \"paymentrate\": x.xx, (numeric) The average rate of payments per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" + " \"shielded_paymentrate\": x.xx, (numeric) The average rate of shielded payments per second in the window. Only returned if \"window_interval\" is > 0 and zindex=1.\n" " \"shielded_txcount\": xxxxx, (numeric) The total number of shielded transactions in the chain up to that point. Only returned if zindex=1\n" " \"fully_shielded_txcount\": xxxxx, (numeric) The total number of fully shielded transactions (z2z) in the chain up to that point. Only returned if zindex=1\n" " \"shielding_txcount\": xxxxx, (numeric) The total number of shielding transactions (t=>z) in the chain up to that point. Only returned if zindex=1\n"