]> Git Repo - VerusCoin.git/blob - src/txdb.h
Merge pull request #5440
[VerusCoin.git] / src / txdb.h
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.
5
6 #ifndef BITCOIN_TXDB_H
7 #define BITCOIN_TXDB_H
8
9 #include "leveldbwrapper.h"
10 #include "main.h"
11
12 #include <map>
13 #include <string>
14 #include <utility>
15 #include <vector>
16
17 class CCoins;
18 class uint256;
19
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;
26
27 /** CCoinsView backed by the LevelDB coin database (chainstate/) */
28 class CCoinsViewDB : public CCoinsView
29 {
30 protected:
31     CLevelDBWrapper db;
32 public:
33     CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
34
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;
40 };
41
42 /** Access to the block database (blocks/index/) */
43 class CBlockTreeDB : public CLevelDBWrapper
44 {
45 public:
46     CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
47 private:
48     CBlockTreeDB(const CBlockTreeDB&);
49     void operator=(const CBlockTreeDB&);
50 public:
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();
61 };
62
63 #endif // BITCOIN_TXDB_H
This page took 0.027542 seconds and 4 git commands to generate.