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 GetCoins(const uint256
&txid
, CCoins
&coins
) const;
38 bool HaveCoins(const uint256
&txid
) const;
39 uint256
GetBestBlock() const;
40 bool BatchWrite(CCoinsMap
&mapCoins
, const uint256
&hashBlock
);
41 bool GetStats(CCoinsStats
&stats
) const;
44 /** Access to the block database (blocks/index/) */
45 class CBlockTreeDB
: public CLevelDBWrapper
48 CBlockTreeDB(size_t nCacheSize
, bool fMemory
= false, bool fWipe
= false);
50 CBlockTreeDB(const CBlockTreeDB
&);
51 void operator=(const CBlockTreeDB
&);
53 bool WriteBatchSync(const std::vector
<std::pair
<int, const CBlockFileInfo
*> >& fileInfo
, int nLastFile
, const std::vector
<const CBlockIndex
*>& blockinfo
);
54 bool ReadBlockFileInfo(int nFile
, CBlockFileInfo
&fileinfo
);
55 bool ReadLastBlockFile(int &nFile
);
56 bool WriteReindexing(bool fReindex
);
57 bool ReadReindexing(bool &fReindex
);
58 bool ReadTxIndex(const uint256
&txid
, CDiskTxPos
&pos
);
59 bool WriteTxIndex(const std::vector
<std::pair
<uint256
, CDiskTxPos
> > &list
);
60 bool WriteFlag(const std::string
&name
, bool fValue
);
61 bool ReadFlag(const std::string
&name
, bool &fValue
);
62 bool LoadBlockIndexGuts();
65 #endif // BITCOIN_TXDB_H