Track shielded spends on disk so we can calculate anonset in real-time correctly
This commit is contained in:
15
src/chain.h
15
src/chain.h
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -276,9 +276,12 @@ public:
|
||||
//! inputs and outputs.
|
||||
int64_t nShieldedTx;
|
||||
|
||||
//! (memory only) Number of shielded outputs in the block up to and including this block.
|
||||
//! (memory only) Number of shielded outputs
|
||||
int64_t nShieldedOutputs;
|
||||
|
||||
//! (memory only) Number of shielded spends
|
||||
int64_t nShieldedSpends;
|
||||
|
||||
//! (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...
|
||||
@@ -332,6 +335,9 @@ public:
|
||||
//! (memory only) Number of shielded outputs in the chain up to and including this block.
|
||||
int64_t nChainShieldedOutputs;
|
||||
|
||||
//! (memory only) Number of shielded spends in the chain up to and including this block.
|
||||
int64_t nChainShieldedSpends;
|
||||
|
||||
//! (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...
|
||||
@@ -429,18 +435,20 @@ public:
|
||||
nChainNotarizations = 0;
|
||||
nChainFullyShieldedTx = 0;
|
||||
nChainShieldedOutputs = 0;
|
||||
nChainShieldedSpends = 0;
|
||||
nChainShieldedPayments = 0;
|
||||
nChainShieldingPayments = 0;
|
||||
nChainDeshieldingPayments = 0;
|
||||
nChainFullyShieldedPayments = 0;
|
||||
|
||||
// Shieldex Index stats
|
||||
// Shielded Index stats
|
||||
nPayments = 0;
|
||||
nShieldedTx = 0;
|
||||
nShieldingTx = 0;
|
||||
nNotarizations = 0;
|
||||
nDeshieldingTx = 0;
|
||||
nShieldedOutputs = 0;
|
||||
nShieldedSpends = 0;
|
||||
nFullyShieldedTx = 0;
|
||||
nShieldedPayments = 0;
|
||||
nShieldingPayments = 0;
|
||||
@@ -679,6 +687,7 @@ public:
|
||||
READWRITE(nDeshieldingPayments);
|
||||
READWRITE(nFullyShieldedPayments);
|
||||
READWRITE(nShieldedOutputs);
|
||||
READWRITE(nShieldedSpends);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -4734,7 +4734,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
||||
CAmount sproutValue = 0;
|
||||
CAmount saplingValue = 0;
|
||||
bool isShieldedTx = false;
|
||||
unsigned int nShieldedSpends=0,nShieldedOutputs=0,nPayments=0, nShieldedOutputsInBlock=0;
|
||||
unsigned int nShieldedSpends=0,nShieldedSpendsInBlock=0,nShieldedOutputs=0,nPayments=0, nShieldedOutputsInBlock=0;
|
||||
unsigned int nShieldedTx=0,nFullyShieldedTx=0,nDeshieldingTx=0,nShieldingTx=0;
|
||||
unsigned int nShieldedPayments=0,nFullyShieldedPayments=0,nShieldingPayments=0,nDeshieldingPayments=0;
|
||||
unsigned int nNotarizations=0;
|
||||
@@ -4822,8 +4822,9 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
||||
// No shielded payments, add transparent payments minus a change address
|
||||
nPayments += tx.vout.size() > 1 ? tx.vout.size()-1 : tx.vout.size();
|
||||
}
|
||||
// To calculate the anonset we must track the sum of zouts in every tx, in every block. -- Duke
|
||||
// To calculate the anonset we must track the sum of spends and zouts in every tx, in every block. -- Duke
|
||||
nShieldedOutputsInBlock += nShieldedOutputs;
|
||||
nShieldedSpendsInBlock += nShieldedSpends;
|
||||
}
|
||||
|
||||
pindexNew->nSproutValue = sproutValue;
|
||||
@@ -4840,6 +4841,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
|
||||
pindexNew->nPayments = nPayments;
|
||||
pindexNew->nShieldedTx = nShieldedTx;
|
||||
pindexNew->nShieldedOutputs = nShieldedOutputsInBlock;
|
||||
pindexNew->nShieldedSpends = nShieldedSpendsInBlock;
|
||||
pindexNew->nFullyShieldedTx = nFullyShieldedTx;
|
||||
pindexNew->nDeshieldingTx = nDeshieldingTx;
|
||||
pindexNew->nShieldingTx = nShieldingTx;
|
||||
|
||||
@@ -2003,8 +2003,9 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk
|
||||
ret.pushKV("shielding_payments", (int64_t)pindex->nChainShieldingPayments);
|
||||
|
||||
int64_t nullifierCount = pwalletMain->NullifierCount();
|
||||
//TODO: this is unreliable, is only a cache or subset of total nullifiers
|
||||
ret.pushKV("nullifiers", (int64_t)nullifierCount);
|
||||
ret.pushKV("shielded_pool_size", (int64_t)pindex->nChainShieldedOutputs - nullifierCount);
|
||||
ret.pushKV("shielded_pool_size", (int64_t)(pindex->nChainShieldedOutputs - pindex->nChainShieldedSpends));
|
||||
ret.pushKV("shielded_outputs", (int64_t)pindex->nChainShieldedOutputs);
|
||||
}
|
||||
|
||||
|
||||
@@ -723,6 +723,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
||||
pindexNew->nPayments = diskindex.nPayments;
|
||||
pindexNew->nShieldedTx = diskindex.nShieldedTx;
|
||||
pindexNew->nShieldedOutputs = diskindex.nShieldedOutputs;
|
||||
pindexNew->nShieldedSpends = diskindex.nShieldedSpends;
|
||||
pindexNew->nShieldedPayments = diskindex.nShieldedPayments;
|
||||
pindexNew->nShieldingTx = diskindex.nShieldingTx;
|
||||
pindexNew->nShieldingPayments = diskindex.nShieldingPayments;
|
||||
|
||||
Reference in New Issue
Block a user