1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
10 #include "leveldbwrapper.h"
22 //! -dbcache default (MiB)
23 static const int64_t nDefaultDbCache = 100;
24 //! max. -dbcache in (MiB)
25 static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
26 //! min. -dbcache in (MiB)
27 static const int64_t nMinDbCache = 4;
29 /** CCoinsView backed by the LevelDB coin database (chainstate/) */
30 class CCoinsViewDB : public CCoinsView
35 CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
37 bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const;
38 bool GetNullifier(const uint256 &nf) const;
39 bool GetCoins(const uint256 &txid, CCoins &coins) const;
40 bool HaveCoins(const uint256 &txid) const;
41 uint256 GetBestBlock() const;
42 uint256 GetBestAnchor() const;
43 bool BatchWrite(CCoinsMap &mapCoins,
44 const uint256 &hashBlock,
45 const uint256 &hashAnchor,
46 CAnchorsMap &mapAnchors,
47 CNullifiersMap &mapNullifiers);
48 bool GetStats(CCoinsStats &stats) const;
51 /** Access to the block database (blocks/index/) */
52 class CBlockTreeDB : public CLevelDBWrapper
55 CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
57 CBlockTreeDB(const CBlockTreeDB&);
58 void operator=(const CBlockTreeDB&);
60 bool WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo);
61 bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo);
62 bool ReadLastBlockFile(int &nFile);
63 bool WriteReindexing(bool fReindex);
64 bool ReadReindexing(bool &fReindex);
65 bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
66 bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
67 bool WriteFlag(const std::string &name, bool fValue);
68 bool ReadFlag(const std::string &name, bool &fValue);
69 bool LoadBlockIndexGuts();
72 #endif // BITCOIN_TXDB_H