From 5c519f9665abe4a8e4b1bc7617b22704602fb8b2 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 7 Aug 2019 10:15:35 -0400 Subject: [PATCH] Start teaching hushd to track various stats about shielded xtns --- src/chain.h | 28 ++++++++++++++++++++++++++++ src/main.cpp | 5 +++++ 2 files changed, 33 insertions(+) diff --git a/src/chain.h b/src/chain.h index b893e3a06..ce7ca7014 100644 --- a/src/chain.h +++ b/src/chain.h @@ -263,6 +263,29 @@ public: //! Change to 64-bit type when necessary; won't happen before 2030 unsigned int nChainTx; + //! (memory only) Number of shielded transactions (of any kind) in the chain up to and including this block. + //! A shielded transaction is defined as a transaction that contains at least 1 JoinSplit, which includes + //! shielding/de-shielding and other complex transaction possibilties including multiple taddrs/zaddrs as + //! inputs and outputs. + int64_t nShieldedChainTx; + + //! (memory only) Number of fully shielded transactions. A fully shielded transaction is defined + //! as a transaction containing JoinSplits and only shielded inputs and outputs + int64_t nFullyShieldedChainTx; + + //! (memory only) Number of deshielding transactions. A deshielding transaction is defined + //! as a transaction containing JoinSplits and at least one transparent output. + int64_t nDeshieldingChainTx; + + //! (memory only) Number of shielding transactions. A shielding transaction is defined + //! as a transaction containing JoinSplits and at least one transparent input + int64_t nShieldingChainTx; + + + //! (memory only) Number of shielding transactions which contain multiple shielded input notes + //! z_sendmany cannot make these and so it indicates raw shielded transaction usage currently + int64_t nMultipleShieldedInputsChainTx; + //! Verification status of this block. See enum BlockStatus unsigned int nStatus; @@ -321,6 +344,11 @@ public: chainPower = CChainPower(); nTx = 0; nChainTx = 0; + nShieldedChainTx = 0; + nShieldingChainTx = 0; + nDeshieldingChainTx = 0; + nFullyShieldedChainTx = 0; + nMultipleShieldedInputsChainTx = 0; nStatus = 0; nCachedBranchId = boost::none; hashSproutAnchor = uint256(); diff --git a/src/main.cpp b/src/main.cpp index e01cba61f..cef96d381 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4734,6 +4734,11 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl while (!queue.empty()) { CBlockIndex *pindex = queue.front(); queue.pop_front(); + // TODO: Count zxtns properly, even amount=0 xtns + // TODO: count number of joinsplits instead + if(saplingValue>0) { + pindex->nShieldedChainTx = pindex->nShieldedChainTx ? 0 : pindex->nShieldedChainTx + 1; + } pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx; if (pindex->pprev) { if (pindex->pprev->nChainSproutValue && pindex->nSproutValue) {