Improve ntz detection and serialize to disk
This commit is contained in:
12
src/chain.h
12
src/chain.h
@@ -260,6 +260,10 @@ 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;
|
||||
|
||||
// TODO: convert block-stats to unsigned int ?
|
||||
//! (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
|
||||
@@ -310,6 +314,9 @@ public:
|
||||
//! 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
|
||||
@@ -615,8 +622,7 @@ public:
|
||||
READWRITE(VARINT(nStatus));
|
||||
READWRITE(VARINT(nTx));
|
||||
|
||||
// These values only serialized when -zindex=1
|
||||
//if (fZindex != GetBoolArg("-zindex", false)) {
|
||||
// These values only serialized when -zindex enabled
|
||||
if(fZindex) {
|
||||
READWRITE(VARINT(nShieldedTx));
|
||||
READWRITE(VARINT(nShieldingTx));
|
||||
@@ -627,6 +633,8 @@ public:
|
||||
READWRITE(VARINT(nShieldingPayments));
|
||||
READWRITE(VARINT(nDeshieldingPayments));
|
||||
READWRITE(VARINT(nFullyShieldedPayments));
|
||||
|
||||
READWRITE(VARINT(nChainNotarizations));
|
||||
}
|
||||
|
||||
if (nStatus & (BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO))
|
||||
|
||||
@@ -4799,8 +4799,8 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
||||
nShieldedOutputs = tx.vShieldedOutput.size();
|
||||
isShieldedTx = (nShieldedSpends + nShieldedOutputs) > 0 ? true : false;
|
||||
|
||||
|
||||
if(tx.vin.size()==13 && tx.vout.size()==2) {
|
||||
// We want to avoid full verification with a low false-positive rate
|
||||
if(tx.vin.size()==13 && tx.vout.size()==2 && tx.vout[1].scriptPubKey.IsOpReturn() && tx.vout[1].nValue==0) {
|
||||
nNotarizations++;
|
||||
}
|
||||
|
||||
@@ -4875,6 +4875,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
||||
pindexNew->nFullyShieldedPayments = nFullyShieldedPayments;
|
||||
pindexNew->nDeshieldingPayments = nDeshieldingPayments;
|
||||
pindexNew->nShieldingPayments = nShieldingPayments;
|
||||
pindexNew->nNotarizations = nNotarizations;
|
||||
}
|
||||
|
||||
setDirtyBlockIndex.insert(pindexNew);
|
||||
@@ -4891,6 +4892,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
||||
|
||||
if (fZindex) {
|
||||
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx;
|
||||
pindex->nChainNotarizations = (pindex->pprev ? pindex->pprev->nChainNotarizations : 0) + pindex->nNotarizations;
|
||||
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;
|
||||
@@ -6175,6 +6177,7 @@ bool static LoadBlockIndexDB()
|
||||
if (pindex->pprev->nChainTx) {
|
||||
|
||||
if (fZindex) {
|
||||
pindex->nChainNotarizations = pindex->pprev->nChainNotarizations + pindex->nNotarizations;
|
||||
pindex->nChainTx = pindex->pprev->nChainTx + pindex->nTx;
|
||||
pindex->nChainShieldedTx = pindex->pprev->nChainShieldedTx + pindex->nShieldedTx;
|
||||
pindex->nChainShieldedPayments = pindex->pprev->nChainShieldedPayments + pindex->nShieldedPayments;
|
||||
@@ -6199,6 +6202,7 @@ bool static LoadBlockIndexDB()
|
||||
} else {
|
||||
pindex->nChainTx = 0;
|
||||
if (fZindex) {
|
||||
pindex->nChainNotarizations = 0;
|
||||
pindex->nChainShieldedTx = 0;
|
||||
pindex->nChainFullyShieldedTx = 0;
|
||||
pindex->nChainShieldedPayments = 0;
|
||||
@@ -6217,6 +6221,7 @@ bool static LoadBlockIndexDB()
|
||||
pindex->nChainSproutValue = pindex->nSproutValue;
|
||||
pindex->nChainSaplingValue = pindex->nSaplingValue;
|
||||
if (fZindex) {
|
||||
pindex->nChainNotarizations = pindex->nNotarizations;
|
||||
pindex->nChainShieldedTx = pindex->nShieldedTx;
|
||||
pindex->nChainShieldedPayments = pindex->nShieldedPayments;
|
||||
pindex->nChainShieldingTx = pindex->nShieldingTx;
|
||||
|
||||
Reference in New Issue
Block a user