Compiles, RPC gives back some shielded stats, which have bugs
This commit is contained in:
76
src/chain.h
76
src/chain.h
@@ -254,22 +254,18 @@ public:
|
|||||||
//! (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
|
//! (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
|
||||||
CChainPower chainPower;
|
CChainPower chainPower;
|
||||||
|
|
||||||
|
// block stats
|
||||||
//! Number of transactions in this block.
|
//! Number of transactions in this block.
|
||||||
//! Note: in a potential headers-first mode, this number cannot be relied upon
|
//! Note: in a potential headers-first mode, this number cannot be relied upon
|
||||||
unsigned int nTx;
|
unsigned int nTx;
|
||||||
|
|
||||||
//! (memory only) Number of transactions in the chain up to and including this block.
|
//! (memory only) Number of payments (shielded or transparent) in the block
|
||||||
//! This value will be non-zero only if and only if transactions for this block and all its parents are available.
|
|
||||||
//! Change to 64-bit type when necessary; won't happen before 2030
|
|
||||||
unsigned int nChainTx;
|
|
||||||
|
|
||||||
//! (memory only) Number of payments (shielded or transparent) in the chain
|
|
||||||
//! up to and including this block. One transaction can contain one or more
|
//! up to and including this block. One transaction can contain one or more
|
||||||
//! payments. This stat allows us to calculate ratios of shielded/transparent
|
//! payments. This stat allows us to calculate ratios of shielded/transparent
|
||||||
//! when combined with shielded payment stats
|
//! when combined with shielded payment stats
|
||||||
int64_t nChainPayments;
|
int64_t nPayments;
|
||||||
|
|
||||||
//! (memory only) Number of shielded transactions (of any kind) in the chain up to and including this block.
|
//! (memory only) Number of shielded transactions (of any kind) in the block up to and including this block.
|
||||||
//! A shielded transaction is defined as a transaction that contains at least 1 JoinSplit, which includes
|
//! 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
|
//! shielding/de-shielding and other complex transaction possibilties including multiple taddrs/zaddrs as
|
||||||
//! inputs and outputs.
|
//! inputs and outputs.
|
||||||
@@ -305,9 +301,56 @@ public:
|
|||||||
// i.e. t->z or t->(z,t) or z->(z,z,t)
|
// i.e. t->z or t->(z,t) or z->(z,z,t)
|
||||||
int64_t nShieldingTx;
|
int64_t nShieldingTx;
|
||||||
|
|
||||||
//! (memory only) Number of shielded transactions which contain multiple shielded input notes
|
|
||||||
//! z_sendmany cannot make these and so it indicates raw shielded transaction usage currently
|
|
||||||
int64_t nMultipleShieldedInputsTx;
|
// chain stats
|
||||||
|
//! (memory only) Number of transactions in the chain up to and including this block.
|
||||||
|
//! This value will be non-zero only if and only if transactions for this block and all its parents are available.
|
||||||
|
//! Change to 64-bit type when necessary; won't happen before 2030
|
||||||
|
unsigned int nChainTx;
|
||||||
|
|
||||||
|
//! (memory only) Number of payments (shielded or transparent) in the chain
|
||||||
|
//! up to and including this block. One transaction can contain one or more
|
||||||
|
//! payments. This stat allows us to calculate ratios of shielded/transparent
|
||||||
|
//! when combined with shielded payment stats
|
||||||
|
int64_t nChainPayments;
|
||||||
|
|
||||||
|
//! (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 nChainShieldedTx;
|
||||||
|
|
||||||
|
//! (memory only) Number of fully shielded transactions. A fully shielded transaction is defined
|
||||||
|
//! as a transaction containing JoinSplits and only shielded inputs and outputs, i.e. no transparent
|
||||||
|
// inputs or outputs: z->z or z->(z,z) or z->(z,z,z,) etc...
|
||||||
|
int64_t nChainFullyShieldedTx;
|
||||||
|
|
||||||
|
//! (memory only) Number of shielding payments. A shielding payment is defined
|
||||||
|
//! as having a shielded output but transparent input: t->z
|
||||||
|
int64_t nChainShieldingPayments;
|
||||||
|
|
||||||
|
//! (memory only) Number of shielded payments. A shielded payment is defined
|
||||||
|
//! as having a shielded input or output: t->z or z->t
|
||||||
|
int64_t nChainShieldedPayments;
|
||||||
|
|
||||||
|
//! (memory only) Number of fully shielded payments. A fully shielded payment is defined
|
||||||
|
//! as having a shielded input and shielded output: z->z
|
||||||
|
int64_t nChainFullyShieldedPayments;
|
||||||
|
|
||||||
|
//! (memory only) Number of deshielding transactions. A deshielding transaction is defined
|
||||||
|
//! as a transaction containing JoinSplits and at least one transparent output.
|
||||||
|
int64_t nChainDeshieldingTx;
|
||||||
|
|
||||||
|
//! (memory only) Number of deshielding payments. A deshielding payment is defined
|
||||||
|
//! as one transparent input and one shielded output: z->t
|
||||||
|
int64_t nChainDeshieldingPayments;
|
||||||
|
|
||||||
|
//! (memory only) Number of shielding transactions. A shielding transaction is defined
|
||||||
|
//! as a transaction containing JoinSplits and at least one transparent input
|
||||||
|
// i.e. t->z or t->(z,t) or z->(z,z,t)
|
||||||
|
int64_t nChainShieldingTx;
|
||||||
|
|
||||||
|
|
||||||
//! Verification status of this block. See enum BlockStatus
|
//! Verification status of this block. See enum BlockStatus
|
||||||
unsigned int nStatus;
|
unsigned int nStatus;
|
||||||
@@ -367,6 +410,15 @@ public:
|
|||||||
chainPower = CChainPower();
|
chainPower = CChainPower();
|
||||||
nTx = 0;
|
nTx = 0;
|
||||||
nChainTx = 0;
|
nChainTx = 0;
|
||||||
|
|
||||||
|
nChainShieldedTx = 0;
|
||||||
|
nChainShieldingTx = 0;
|
||||||
|
nChainDeshieldingTx = 0;
|
||||||
|
nChainFullyShieldedTx = 0;
|
||||||
|
nChainShieldedPayments = 0;
|
||||||
|
nChainShieldingPayments = 0;
|
||||||
|
nChainDeshieldingPayments = 0;
|
||||||
|
nChainFullyShieldedPayments = 0;
|
||||||
nShieldedTx = 0;
|
nShieldedTx = 0;
|
||||||
nShieldingTx = 0;
|
nShieldingTx = 0;
|
||||||
nDeshieldingTx = 0;
|
nDeshieldingTx = 0;
|
||||||
@@ -375,7 +427,7 @@ public:
|
|||||||
nShieldingPayments = 0;
|
nShieldingPayments = 0;
|
||||||
nDeshieldingPayments = 0;
|
nDeshieldingPayments = 0;
|
||||||
nFullyShieldedPayments = 0;
|
nFullyShieldedPayments = 0;
|
||||||
nMultipleShieldedInputsTx = 0;
|
|
||||||
nStatus = 0;
|
nStatus = 0;
|
||||||
nCachedBranchId = boost::none;
|
nCachedBranchId = boost::none;
|
||||||
hashSproutAnchor = uint256();
|
hashSproutAnchor = uint256();
|
||||||
|
|||||||
27
src/main.cpp
27
src/main.cpp
@@ -4770,14 +4770,10 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
|||||||
pindexNew->nTx = block.vtx.size();
|
pindexNew->nTx = block.vtx.size();
|
||||||
pindexNew->nChainTx = 0;
|
pindexNew->nChainTx = 0;
|
||||||
pindexNew->nChainPayments = 0;
|
pindexNew->nChainPayments = 0;
|
||||||
pindexNew->nShieldedTx = 0;
|
|
||||||
pindexNew->nShieldingTx = 0;
|
|
||||||
pindexNew->nDeshieldingTx = 0;
|
|
||||||
CAmount sproutValue = 0;
|
CAmount sproutValue = 0;
|
||||||
CAmount saplingValue = 0;
|
CAmount saplingValue = 0;
|
||||||
bool isShieldedTx = false;
|
bool isShieldedTx = false;
|
||||||
|
int64_t nShieldedSpends=0,nShieldedOutputs=0,nPayments=0;
|
||||||
int64_t nShieldedSpends=0,nShieldedOutputs=0,nChainPayments=0;
|
|
||||||
int64_t nShieldedTx=0,nFullyShieldedTx=0,nDeshieldingTx=0,nShieldingTx=0;
|
int64_t nShieldedTx=0,nFullyShieldedTx=0,nDeshieldingTx=0,nShieldingTx=0;
|
||||||
int64_t nShieldedPayments=0,nFullyShieldedPayments=0,nShieldingPayments=0,nDeshieldingPayments=0;
|
int64_t nShieldedPayments=0,nFullyShieldedPayments=0,nShieldingPayments=0,nDeshieldingPayments=0;
|
||||||
|
|
||||||
@@ -4831,12 +4827,14 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
|||||||
// z->(t,t,t) = 3 shielded payments
|
// z->(t,t,t) = 3 shielded payments
|
||||||
nShieldedPayments += tx.vout.size();
|
nShieldedPayments += tx.vout.size();
|
||||||
}
|
}
|
||||||
nChainPayments += nShieldedPayments;
|
//TODO: correctly add shielded payments to total chain payments
|
||||||
|
nPayments += nShieldedPayments;
|
||||||
} else {
|
} else {
|
||||||
// No shielded payments, add transparent payments minus a change address
|
// No shielded payments, add transparent payments minus a change address
|
||||||
nChainPayments += tx.vout.size() > 1 ? tx.vout.size()-1 : tx.vout.size();
|
nPayments += tx.vout.size() > 1 ? tx.vout.size()-1 : tx.vout.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pindexNew->nSproutValue = sproutValue;
|
pindexNew->nSproutValue = sproutValue;
|
||||||
pindexNew->nChainSproutValue = boost::none;
|
pindexNew->nChainSproutValue = boost::none;
|
||||||
pindexNew->nSaplingValue = saplingValue;
|
pindexNew->nSaplingValue = saplingValue;
|
||||||
@@ -4847,8 +4845,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
|||||||
pindexNew->nStatus |= BLOCK_HAVE_DATA;
|
pindexNew->nStatus |= BLOCK_HAVE_DATA;
|
||||||
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
|
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
|
||||||
|
|
||||||
// Store data for later use by gettxchainstats and other RPCs
|
pindexNew->nPayments = nPayments;
|
||||||
pindexNew->nChainPayments = nChainPayments;
|
|
||||||
pindexNew->nShieldedTx = nShieldedTx;
|
pindexNew->nShieldedTx = nShieldedTx;
|
||||||
pindexNew->nFullyShieldedTx = nFullyShieldedTx;
|
pindexNew->nFullyShieldedTx = nFullyShieldedTx;
|
||||||
pindexNew->nDeshieldingTx = nDeshieldingTx;
|
pindexNew->nDeshieldingTx = nDeshieldingTx;
|
||||||
@@ -4870,7 +4867,17 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
|||||||
CBlockIndex *pindex = queue.front();
|
CBlockIndex *pindex = queue.front();
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
|
|
||||||
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
|
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
|
||||||
|
pindex->nChainShieldedTx = (pindex->pprev ? pindex->pprev->nChainShieldedTx : 0) + pindex->nShieldedTx;
|
||||||
|
pindex->nChainFullyShieldedTx = (pindex->pprev ? pindex->pprev->nChainFullyShieldedTx : 0) + pindex->nFullyShieldedTx;
|
||||||
|
pindex->nChainShieldingTx = (pindex->pprev ? pindex->pprev->nChainShieldingTx : 0) + pindex->nShieldingTx;
|
||||||
|
pindex->nChainDeshieldingTx = (pindex->pprev ? pindex->pprev->nChainDeshieldingTx : 0) + pindex->nDeshieldingTx;
|
||||||
|
|
||||||
|
pindex->nChainShieldedPayments = (pindex->pprev ? pindex->pprev->nChainShieldedPayments : 0) + pindex->nShieldedPayments;
|
||||||
|
pindex->nChainFullyShieldedPayments = (pindex->pprev ? pindex->pprev->nChainFullyShieldedPayments : 0) + pindex->nFullyShieldedPayments;
|
||||||
|
pindex->nChainShieldingPayments = (pindex->pprev ? pindex->pprev->nChainShieldingPayments : 0) + pindex->nShieldingPayments;
|
||||||
|
pindex->nChainDeshieldingPayments = (pindex->pprev ? pindex->pprev->nChainDeshieldingPayments : 0) + pindex->nDeshieldingPayments;
|
||||||
|
|
||||||
if (pindex->pprev) {
|
if (pindex->pprev) {
|
||||||
if (pindex->pprev->nChainSproutValue && pindex->nSproutValue) {
|
if (pindex->pprev->nChainSproutValue && pindex->nSproutValue) {
|
||||||
pindex->nChainSproutValue = *pindex->pprev->nChainSproutValue + *pindex->nSproutValue;
|
pindex->nChainSproutValue = *pindex->pprev->nChainSproutValue + *pindex->nSproutValue;
|
||||||
|
|||||||
@@ -1994,14 +1994,13 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp)
|
|||||||
int nTimeDiff = pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast();
|
int nTimeDiff = pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast();
|
||||||
int nTxDiff = pindex->nChainTx - pindexPast->nChainTx;
|
int nTxDiff = pindex->nChainTx - pindexPast->nChainTx;
|
||||||
int64_t nPaymentsDiff = pindex->nChainPayments - pindexPast->nChainPayments;
|
int64_t nPaymentsDiff = pindex->nChainPayments - pindexPast->nChainPayments;
|
||||||
int64_t nShieldedPaymentsDiff = pindex->nShieldedPayments - pindexPast->nShieldedPayments;
|
int64_t nShieldedPaymentsDiff = pindex->nChainShieldedPayments - pindexPast->nChainShieldedPayments;
|
||||||
|
|
||||||
UniValue ret(UniValue::VOBJ);
|
UniValue ret(UniValue::VOBJ);
|
||||||
ret.pushKV("time", (int64_t)pindex->nTime);
|
ret.pushKV("time", (int64_t)pindex->nTime);
|
||||||
ret.pushKV("txcount", (int64_t)pindex->nChainTx);
|
ret.pushKV("txcount", (int64_t)pindex->nChainTx);
|
||||||
ret.pushKV("shielded_txcount", (int64_t)pindex->nShieldedTx);
|
ret.pushKV("shielded_txcount", (int64_t)pindex->nChainShieldedTx);
|
||||||
ret.pushKV("fully_shielded_txcount", (int64_t)pindex->nFullyShieldedTx);
|
ret.pushKV("fully_shielded_txcount", (int64_t)pindex->nFullyShieldedTx);
|
||||||
|
|
||||||
ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex());
|
ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex());
|
||||||
ret.pushKV("window_block_count", blockcount);
|
ret.pushKV("window_block_count", blockcount);
|
||||||
if (blockcount > 0) {
|
if (blockcount > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user