]> Git Repo - VerusCoin.git/blob - src/txdb.h
Auto merge of #2000 - str4d:1622-bdb-m4-rename, r=ebfull
[VerusCoin.git] / src / txdb.h
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.
5
6 #ifndef BITCOIN_TXDB_H
7 #define BITCOIN_TXDB_H
8
9 #include "coins.h"
10 #include "leveldbwrapper.h"
11
12 #include <map>
13 #include <string>
14 #include <utility>
15 #include <vector>
16
17 class CBlockFileInfo;
18 class CBlockIndex;
19 struct CDiskTxPos;
20 class uint256;
21
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;
28
29 /** CCoinsView backed by the LevelDB coin database (chainstate/) */
30 class CCoinsViewDB : public CCoinsView
31 {
32 protected:
33     CLevelDBWrapper db;
34 public:
35     CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
36
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;
49 };
50
51 /** Access to the block database (blocks/index/) */
52 class CBlockTreeDB : public CLevelDBWrapper
53 {
54 public:
55     CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
56 private:
57     CBlockTreeDB(const CBlockTreeDB&);
58     void operator=(const CBlockTreeDB&);
59 public:
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();
70 };
71
72 #endif // BITCOIN_TXDB_H
This page took 0.026923 seconds and 4 git commands to generate.