1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
9 #include "leveldbwrapper.h"
20 //! -dbcache default (MiB)
21 static const int64_t nDefaultDbCache = 100;
22 //! max. -dbcache in (MiB)
23 static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 4096 : 1024;
24 //! min. -dbcache in (MiB)
25 static const int64_t nMinDbCache = 4;
27 /** CCoinsView backed by the LevelDB coin database (chainstate/) */
28 class CCoinsViewDB : public CCoinsView
33 CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
35 bool GetCoins(const uint256 &txid, CCoins &coins) const;
36 bool HaveCoins(const uint256 &txid) const;
37 uint256 GetBestBlock() const;
38 bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
39 bool GetStats(CCoinsStats &stats) const;
42 /** Access to the block database (blocks/index/) */
43 class CBlockTreeDB : public CLevelDBWrapper
46 CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
48 CBlockTreeDB(const CBlockTreeDB&);
49 void operator=(const CBlockTreeDB&);
51 bool WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo);
52 bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo);
53 bool ReadLastBlockFile(int &nFile);
54 bool WriteReindexing(bool fReindex);
55 bool ReadReindexing(bool &fReindex);
56 bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
57 bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
58 bool WriteFlag(const std::string &name, bool fValue);
59 bool ReadFlag(const std::string &name, bool &fValue);
60 bool LoadBlockIndexGuts();
63 #endif // BITCOIN_TXDB_H