Add UpdatedBlockTip signal to CMainSignals and CValidationInterface
[bitcoinplatinum.git] / src / txdb.h
blobbef5dc9fd18fedf4c015336753dfc3acb8220833
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.
6 #ifndef BITCOIN_TXDB_H
7 #define BITCOIN_TXDB_H
9 #include "coins.h"
10 #include "leveldbwrapper.h"
12 #include <map>
13 #include <string>
14 #include <utility>
15 #include <vector>
17 class CBlockFileInfo;
18 class CBlockIndex;
19 struct CDiskTxPos;
20 class uint256;
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
32 protected:
33 CLevelDBWrapper db;
34 public:
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
47 public:
48 CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
49 private:
50 CBlockTreeDB(const CBlockTreeDB&);
51 void operator=(const CBlockTreeDB&);
52 public:
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