Port zindex code from old patches; compiles and seems to work when zindex is disabled

This commit is contained in:
Duke Leto
2019-12-17 12:08:14 -05:00
parent 2492ac8c3a
commit fbfdc8f40f
4 changed files with 301 additions and 18 deletions

View File

@@ -138,6 +138,7 @@ class CBlockIndex;
// that involves mining in secret completely ineffective, even before dPOW, unless a large part
// of the staking supply is also controlled. It also enables a faster deterministic convergence,
// aided by both POS and POW.
// TODO: delete this junk
class CChainPower
{
public:
@@ -260,11 +261,59 @@ public:
//! Note: in a potential headers-first mode, this number cannot be relied upon
unsigned int nTx;
//! Number of notarization transactions in this block.
unsigned int nNotarizations;
//! (memory only) Number of payments (shielded or transparent) in the block
//! 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
unsigned int nPayments;
//! (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
//! shielding/de-shielding and other complex transaction possibilties including multiple taddrs/zaddrs as
//! inputs and outputs.
unsigned int nShieldedTx;
//! (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...
unsigned int nFullyShieldedTx;
//! (memory only) Number of shielding payments. A shielding payment is defined
//! as having a shielded output but transparent input: t->z
unsigned int nShieldingPayments;
//! (memory only) Number of shielded payments. A shielded payment is defined
//! as having a shielded input or output: t->z or z->t
unsigned int nShieldedPayments;
//! (memory only) Number of fully shielded payments. A fully shielded payment is defined
//! as having a shielded input and shielded output: z->z
unsigned int nFullyShieldedPayments;
//! (memory only) Number of deshielding transactions. A deshielding transaction is defined
//! as a transaction containing JoinSplits and at least one transparent output.
unsigned int nDeshieldingTx;
//! (memory only) Number of deshielding payments. A deshielding payment is defined
//! as one transparent input and one shielded output: z->t
unsigned int nDeshieldingPayments;
//! (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)
unsigned int nShieldingTx;
//! (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;
//! Number of notarization transactions in this chain
int64_t nChainNotarizations;
//! (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
@@ -275,41 +324,37 @@ public:
//! 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 nShieldedTx;
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 nFullyShieldedTx;
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 nShieldingPayments;
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 nShieldedPayments;
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 nFullyShieldedPayments;
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 nDeshieldingTx;
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 nDeshieldingPayments;
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 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;
int64_t nChainShieldingTx;
//! Verification status of this block. See enum BlockStatus
unsigned int nStatus;
@@ -369,6 +414,16 @@ public:
chainPower = CChainPower();
nTx = 0;
nChainTx = 0;
nChainPayments = 0;
nChainShieldedTx = 0;
nChainShieldingTx = 0;
nChainDeshieldingTx = 0;
nChainNotarizations = 0;
nChainFullyShieldedTx = 0;
nChainShieldedPayments = 0;
nChainShieldingPayments = 0;
nChainDeshieldingPayments = 0;
nChainFullyShieldedPayments = 0;
nShieldedTx = 0;
nShieldingTx = 0;
nDeshieldingTx = 0;
@@ -377,7 +432,6 @@ public:
nShieldingPayments = 0;
nDeshieldingPayments = 0;
nFullyShieldedPayments = 0;
nMultipleShieldedInputsTx = 0;
nStatus = 0;
nCachedBranchId = boost::none;
hashSproutAnchor = uint256();
@@ -553,6 +607,21 @@ public:
READWRITE(VARINT(nStatus));
READWRITE(VARINT(nTx));
// These values only serialized when -zindex enabled
if((s.GetType() & SER_DISK) && fZindex) {
READWRITE(VARINT(nShieldedTx));
READWRITE(VARINT(nShieldingTx));
READWRITE(VARINT(nDeshieldingTx));
READWRITE(VARINT(nFullyShieldedTx));
READWRITE(VARINT(nShieldedPayments));
READWRITE(VARINT(nShieldingPayments));
READWRITE(VARINT(nDeshieldingPayments));
READWRITE(VARINT(nFullyShieldedPayments));
READWRITE(VARINT(nNotarizations));
}
if (nStatus & (BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO))
READWRITE(VARINT(nFile));
if (nStatus & BLOCK_HAVE_DATA)