25 static constexpr
int MAX_BLOCK_COINSDB_USAGE = 10;
27 static const int64_t nDefaultDbCache = 300;
29 static const int64_t nDefaultDbBatchSize = 16 << 20;
31 static const int64_t nMaxDbCache =
sizeof(
void*) > 4 ? 16384 : 1024;
33 static const int64_t nMinDbCache = 4;
35 static const int64_t nMaxBlockDBCache = 2;
39 static const int64_t nMaxBlockDBAndTxIndexCache = 1024;
41 static const int64_t nMaxCoinsDBCache = 8;
76 explicit CCoinsViewDB(
size_t nCacheSize,
bool fMemory =
false,
bool fWipe =
false);
90 const uint256& hashSaplingAnchor,
130 explicit CBlockTreeDB(
size_t nCacheSize,
bool fMemory =
false,
bool fWipe =
false);
136 bool WriteBatchSync(
const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo,
int nLastFile,
const std::vector<const CBlockIndex*>& blockinfo);
142 bool WriteTxIndex(
const std::vector<std::pair<uint256, CDiskTxPos> >& vect);
146 bool ReadInt(
const std::string&
name,
int& nValue);
154 explicit CZerocoinDB(
size_t nCacheSize,
bool fMemory =
false,
bool fWipe =
false);
171 bool ReadAll(std::map<std::pair<uint32_t, libzerocoin::CoinDenomination>,
int>& mapCheckpoints);
182 std::map<std::pair<uint32_t, libzerocoin::CoinDenomination>,
int>
mapCheckpoints;
187 assert(
db !=
nullptr);
PublicCoin class for the Zerocoin library.
CoinSpend class for the Zerocoin library.
void Erase(uint32_t checksum, libzerocoin::CoinDenomination denom)
Optional< int > Get(uint32_t checksum, libzerocoin::CoinDenomination denom)
std::map< std::pair< uint32_t, libzerocoin::CoinDenomination >, int > mapCheckpoints
AccumulatorCache(CZerocoinDB *_db)
void Set(uint32_t checksum, libzerocoin::CoinDenomination denom, int height)
The block chain is a tree shaped structure starting with the genesis block at the root,...
Access to the block database (blocks/index/)
CBlockTreeDB(const CBlockTreeDB &)=delete
bool WriteTxIndex(const std::vector< std::pair< uint256, CDiskTxPos > > &vect)
bool ReadInt(const std::string &name, int &nValue)
bool LoadBlockIndexGuts(std::function< CBlockIndex *(const uint256 &)> insertBlockIndex)
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &info)
CBlockTreeDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
bool WriteReindexing(bool fReindexing)
bool WriteBlockIndex(const CDiskBlockIndex &blockindex)
bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos)
bool WriteInt(const std::string &name, int nValue)
bool WriteBatchSync(const std::vector< std::pair< int, const CBlockFileInfo * > > &fileInfo, int nLastFile, const std::vector< const CBlockIndex * > &blockinfo)
CBlockTreeDB & operator=(const CBlockTreeDB &)=delete
bool ReadFlag(const std::string &name, bool &fValue)
bool ReadReindexing(bool &fReindexing)
bool ReadLastBlockFile(int &nFile)
bool WriteFlag(const std::string &name, bool fValue)
Cursor for iterating over CoinsView state.
Specialization of CCoinsViewCursor to iterate over a CCoinsViewDB.
std::unique_ptr< CDBIterator > pcursor
bool GetKey(COutPoint &key) const
CCoinsViewDBCursor(CDBIterator *pcursorIn, const uint256 &hashBlockIn)
unsigned int GetValueSize() const
std::pair< char, COutPoint > keyTmp
bool GetValue(Coin &coin) const
CCoinsView backed by the LevelDB coin database (chainstate/)
uint256 GetBestAnchor() const override
Get the current "tip" or the latest anchored tree root in the chain.
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const override
Retrieve the tree (Sapling) at a particular anchored root in the chain.
CCoinsViewDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
bool GetNullifier(const uint256 &nf) const override
Determine whether a nullifier is spent or not.
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether we have data for a given outpoint.
bool Upgrade()
Attempt to update from an older database format. Returns whether an error occurred.
CCoinsViewCursor * Cursor() const override
Get a cursor to iterate over the whole state.
uint256 GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
bool BatchWriteSapling(const uint256 &hashSaplingAnchor, CAnchorsSaplingMap &mapSaplingAnchors, CNullifiersMap &mapSaplingNullifiers, CDBBatch &batch)
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const uint256 &hashSaplingAnchor, CAnchorsSaplingMap &mapSaplingAnchors, CNullifiersMap &mapSaplingNullifiers) override
Do a bulk modification (multiple Coin changes + BestBlock change).
std::vector< uint256 > GetHeadBlocks() const override
Retrieve the range of blocks that may have been only partially written.
size_t EstimateSize() const override
Estimate database size (0 if not implemented)
Abstract view on the open txout dataset.
Batch of changes queued to be written to a CDBWrapper.
An outpoint - a combination of a transaction hash and an index n into its vout.
Zerocoin database (zerocoin/)
void operator=(const CZerocoinDB &)
bool WriteAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom, const int nHeight)
Accumulators (only for zPoS IBD): [checksum, denom] --> block height.
CZerocoinDB(const CZerocoinDB &)
bool ReadCoinSpend(const CBigNum &bnSerial, uint256 &txHash)
bool ReadAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom, int &nHeightRet)
bool EraseAccChecksum(const uint32_t nChecksum, const libzerocoin::CoinDenomination denom)
CZerocoinDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
bool EraseCoinSpend(const CBigNum &bnSerial)
bool WriteCoinSpendBatch(const std::vector< std::pair< CBigNum, uint256 > > &spendInfo)
Write zPIV spends to the zerocoinDB in a batch Pair of: CBigNum -> coinSerialNumber and uint256 -> tx...
bool ReadAll(std::map< std::pair< uint32_t, libzerocoin::CoinDenomination >, int > &mapCheckpoints)
std::unordered_map< uint256, CAnchorsSaplingCacheEntry, SaltedIdHasher > CAnchorsSaplingMap
std::unordered_map< COutPoint, CCoinsCacheEntry, SaltedOutpointHasher > CCoinsMap
std::unordered_map< uint256, CNullifiersCacheEntry, SaltedIdHasher > CNullifiersMap
boost::optional< T > Optional
Substitute for C++17 std::optional.
#define READWRITEAS(type, obj)
SERIALIZE_METHODS(CDiskTxPos, obj)
CDiskTxPos(const FlatFilePos &blockIn, unsigned int nTxOffsetIn)