Track net value entering and exiting the Sprout circuit
Delta values will be stored for new blocks; old blocks can be filled in by re-indexing. The net value currently in the Sprout circuit is only calculated when delta values for all previous blocks are present.
This commit is contained in:
21
src/chain.h
21
src/chain.h
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
static const int SPROUT_VALUE_VERSION = 1001400;
|
||||
|
||||
struct CDiskBlockPos
|
||||
{
|
||||
int nFile;
|
||||
@@ -144,6 +146,15 @@ public:
|
||||
//! (memory only) The anchor for the tree state up to the end of this block
|
||||
uint256 hashAnchorEnd;
|
||||
|
||||
//! Change in value held by the Sprout circuit over this block.
|
||||
//! Will be boost::none for older blocks on old nodes until a reindex has taken place.
|
||||
boost::optional<CAmount> nSproutValue;
|
||||
|
||||
//! (memory only) Total value held by the Sprout circuit up to and including this block.
|
||||
//! Will be boost::none for on old nodes until a reindex has taken place.
|
||||
//! Will be boost::none if nChainTx is zero.
|
||||
boost::optional<CAmount> nChainSproutValue;
|
||||
|
||||
//! block header
|
||||
int nVersion;
|
||||
uint256 hashMerkleRoot;
|
||||
@@ -172,6 +183,8 @@ public:
|
||||
hashAnchor = uint256();
|
||||
hashAnchorEnd = uint256();
|
||||
nSequenceId = 0;
|
||||
nSproutValue = boost::none;
|
||||
nChainSproutValue = boost::none;
|
||||
|
||||
nVersion = 0;
|
||||
hashMerkleRoot = uint256();
|
||||
@@ -339,6 +352,14 @@ public:
|
||||
READWRITE(nBits);
|
||||
READWRITE(nNonce);
|
||||
READWRITE(nSolution);
|
||||
|
||||
// Only read/write nSproutValue if the client version used to create
|
||||
// this index was storing them.
|
||||
// TODO: See if we can get away with not serializing the boost::optional
|
||||
// one-byte header, without requiring users to reindex on upgrade.
|
||||
if (nType & SER_DISK && nVersion >= SPROUT_VALUE_VERSION) {
|
||||
READWRITE(nSproutValue);
|
||||
}
|
||||
}
|
||||
|
||||
uint256 GetBlockHash() const
|
||||
|
||||
Reference in New Issue
Block a user