]>
Commit | Line | Data |
---|---|---|
2d8a4829 | 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto |
db0e8ccd | 2 | // Copyright (c) 2009-2013 The Bitcoin developers |
2d8a4829 PW |
3 | // Distributed under the MIT/X11 software license, see the accompanying |
4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
51ed9ec9 | 5 | |
4ca60bba PW |
6 | #ifndef BITCOIN_TXDB_LEVELDB_H |
7 | #define BITCOIN_TXDB_LEVELDB_H | |
2d8a4829 | 8 | |
b64187d0 | 9 | #include "leveldbwrapper.h" |
51ed9ec9 BD |
10 | #include "main.h" |
11 | ||
12 | #include <map> | |
13 | #include <string> | |
14 | #include <utility> | |
15 | #include <vector> | |
16 | ||
51ed9ec9 BD |
17 | class CCoins; |
18 | class uint256; | |
2d8a4829 | 19 | |
82e96006 | 20 | // -dbcache default (MiB) |
ad54a9b8 | 21 | static const int64_t nDefaultDbCache = 100; |
82e96006 | 22 | // max. -dbcache in (MiB) |
ad54a9b8 | 23 | static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 4096 : 1024; |
82e96006 | 24 | // min. -dbcache in (MiB) |
ad54a9b8 | 25 | static const int64_t nMinDbCache = 4; |
82e96006 | 26 | |
8fdc94cc | 27 | /** CCoinsView backed by the LevelDB coin database (chainstate/) */ |
4ca60bba PW |
28 | class CCoinsViewDB : public CCoinsView |
29 | { | |
30 | protected: | |
b64187d0 | 31 | CLevelDBWrapper db; |
4ca60bba | 32 | public: |
7fea4846 | 33 | CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); |
4ca60bba | 34 | |
a3dc587a | 35 | bool GetCoins(const uint256 &txid, CCoins &coins) const; |
f369d02c | 36 | bool SetCoins(const uint256 &txid, const CCoins &coins); |
a3dc587a DK |
37 | bool HaveCoins(const uint256 &txid) const; |
38 | uint256 GetBestBlock() const; | |
84674082 | 39 | bool SetBestBlock(const uint256 &hashBlock); |
b0875eb3 | 40 | bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock); |
a3dc587a | 41 | bool GetStats(CCoinsStats &stats) const; |
4ca60bba PW |
42 | }; |
43 | ||
8fdc94cc | 44 | /** Access to the block database (blocks/index/) */ |
b64187d0 | 45 | class CBlockTreeDB : public CLevelDBWrapper |
4ca60bba PW |
46 | { |
47 | public: | |
7fea4846 | 48 | CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); |
4ca60bba PW |
49 | private: |
50 | CBlockTreeDB(const CBlockTreeDB&); | |
51 | void operator=(const CBlockTreeDB&); | |
52 | public: | |
53 | bool WriteBlockIndex(const CDiskBlockIndex& blockindex); | |
4ca60bba PW |
54 | bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo); |
55 | bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo); | |
56 | bool ReadLastBlockFile(int &nFile); | |
57 | bool WriteLastBlockFile(int nFile); | |
7fea4846 PW |
58 | bool WriteReindexing(bool fReindex); |
59 | bool ReadReindexing(bool &fReindex); | |
2d1fa42e PW |
60 | bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos); |
61 | bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list); | |
62 | bool WriteFlag(const std::string &name, bool fValue); | |
63 | bool ReadFlag(const std::string &name, bool &fValue); | |
4ca60bba PW |
64 | bool LoadBlockIndexGuts(); |
65 | }; | |
66 | ||
67 | #endif // BITCOIN_TXDB_LEVELDB_H |