]>
Commit | Line | Data |
---|---|---|
2d8a4829 | 1 | // Copyright (c) 2009-2010 Satoshi Nakamoto |
f914f1a7 | 2 | // Copyright (c) 2009-2014 The Bitcoin Core developers |
fa94b9d5 | 3 | // Distributed under the MIT software license, see the accompanying |
2d8a4829 | 4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
51ed9ec9 | 5 | |
84738627 PJ |
6 | #ifndef BITCOIN_TXDB_H |
7 | #define BITCOIN_TXDB_H | |
2d8a4829 | 8 | |
8a893c94 | 9 | #include "coins.h" |
b64187d0 | 10 | #include "leveldbwrapper.h" |
51ed9ec9 BD |
11 | |
12 | #include <map> | |
13 | #include <string> | |
14 | #include <utility> | |
15 | #include <vector> | |
16 | ||
8a893c94 JT |
17 | class CBlockFileInfo; |
18 | class CBlockIndex; | |
63e4c9cd | 19 | struct CDiskTxPos; |
51ed9ec9 | 20 | class uint256; |
2d8a4829 | 21 | |
fa94b9d5 | 22 | //! -dbcache default (MiB) |
ad54a9b8 | 23 | static const int64_t nDefaultDbCache = 100; |
fa94b9d5 | 24 | //! max. -dbcache in (MiB) |
b3ed4236 | 25 | static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024; |
fa94b9d5 | 26 | //! min. -dbcache in (MiB) |
ad54a9b8 | 27 | static const int64_t nMinDbCache = 4; |
82e96006 | 28 | |
8fdc94cc | 29 | /** CCoinsView backed by the LevelDB coin database (chainstate/) */ |
4ca60bba PW |
30 | class CCoinsViewDB : public CCoinsView |
31 | { | |
32 | protected: | |
b64187d0 | 33 | CLevelDBWrapper db; |
4ca60bba | 34 | public: |
7fea4846 | 35 | CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); |
4ca60bba | 36 | |
434f3284 | 37 | bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; |
b78daf7d | 38 | bool GetNullifier(const uint256 &nf) const; |
a3dc587a | 39 | bool GetCoins(const uint256 &txid, CCoins &coins) const; |
a3dc587a DK |
40 | bool HaveCoins(const uint256 &txid) const; |
41 | uint256 GetBestBlock() const; | |
9f25631d SB |
42 | uint256 GetBestAnchor() const; |
43 | bool BatchWrite(CCoinsMap &mapCoins, | |
44 | const uint256 &hashBlock, | |
45 | const uint256 &hashAnchor, | |
45d6bee9 | 46 | CAnchorsMap &mapAnchors, |
bb64be52 | 47 | CNullifiersMap &mapNullifiers); |
a3dc587a | 48 | bool GetStats(CCoinsStats &stats) const; |
4ca60bba PW |
49 | }; |
50 | ||
8fdc94cc | 51 | /** Access to the block database (blocks/index/) */ |
b64187d0 | 52 | class CBlockTreeDB : public CLevelDBWrapper |
4ca60bba PW |
53 | { |
54 | public: | |
7fea4846 | 55 | CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); |
4ca60bba PW |
56 | private: |
57 | CBlockTreeDB(const CBlockTreeDB&); | |
58 | void operator=(const CBlockTreeDB&); | |
59 | public: | |
63d1ae55 | 60 | bool WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo); |
4ca60bba | 61 | bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo); |
4ca60bba | 62 | bool ReadLastBlockFile(int &nFile); |
7fea4846 PW |
63 | bool WriteReindexing(bool fReindex); |
64 | bool ReadReindexing(bool &fReindex); | |
2d1fa42e PW |
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); | |
4ca60bba PW |
69 | bool LoadBlockIndexGuts(); |
70 | }; | |
71 | ||
84738627 | 72 | #endif // BITCOIN_TXDB_H |