Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
txdb.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2013 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_TXDB_LEVELDB_H
7 #define BITCOIN_TXDB_LEVELDB_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 CBigNum;
18 class CCoins;
19 class uint256;
20 
21 // -dbcache default (MiB)
22 static const int64_t nDefaultDbCache = 100;
23 // max. -dbcache in (MiB)
24 static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 4096 : 1024;
25 // min. -dbcache in (MiB)
26 static const int64_t nMinDbCache = 4;
27 
29 class CCoinsViewDB : public CCoinsView
30 {
31 protected:
33 public:
34  CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
35 
36  bool GetCoins(const uint256 &txid, CCoins &coins);
37  bool SetCoins(const uint256 &txid, const CCoins &coins);
38  bool HaveCoins(const uint256 &txid);
40  bool SetBestBlock(const uint256 &hashBlock);
41  bool BatchWrite(const std::map<uint256, CCoins> &mapCoins, const uint256 &hashBlock);
42  bool GetStats(CCoinsStats &stats);
43 };
44 
47 {
48 public:
49  CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
50 private:
51  CBlockTreeDB(const CBlockTreeDB&);
52  void operator=(const CBlockTreeDB&);
53 public:
54  bool WriteBlockIndex(const CDiskBlockIndex& blockindex);
55  bool WriteBestInvalidWork(const CBigNum& bnBestInvalidWork);
56  bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo);
57  bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo);
58  bool ReadLastBlockFile(int &nFile);
59  bool WriteLastBlockFile(int nFile);
60  bool WriteReindexing(bool fReindex);
61  bool ReadReindexing(bool &fReindex);
62  bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
63  bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
64  bool WriteFlag(const std::string &name, bool fValue);
65  bool ReadFlag(const std::string &name, bool &fValue);
66  bool LoadBlockIndexGuts();
67 };
68 
69 #endif // BITCOIN_TXDB_LEVELDB_H
bool ReadReindexing(bool &fReindex)
Definition: txdb.cpp:101
bool ReadLastBlockFile(int &nFile)
Definition: txdb.cpp:106
bool WriteBlockIndex(const CDiskBlockIndex &blockindex)
Definition: txdb.cpp:71
bool GetCoins(const uint256 &txid, CCoins &coins)
Definition: txdb.cpp:29
static const int64_t nMinDbCache
Definition: txdb.h:26
pruned version of CTransaction: only retains metadata and unspent transaction outputs ...
Definition: coins.h:68
bool fReindex
Definition: main.cpp:53
bool LoadBlockIndexGuts()
Definition: txdb.cpp:184
void operator=(const CBlockTreeDB &)
Access to the block database (blocks/index/)
Definition: txdb.h:46
Abstract view on the open txout dataset.
Definition: coins.h:258
CLevelDBWrapper db
Definition: txdb.h:32
C++ wrapper for BIGNUM (OpenSSL bignum)
Definition: bignum.h:57
static const int64_t nDefaultDbCache
Definition: txdb.h:22
bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo)
Definition: txdb.cpp:82
Used to marshal pointers into hashes for db storage.
Definition: main.h:871
bool WriteLastBlockFile(int nFile)
Definition: txdb.cpp:90
bool ReadFlag(const std::string &name, bool &fValue)
Definition: txdb.cpp:176
CBlockTreeDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: txdb.cpp:68
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo)
Definition: txdb.cpp:86
bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos)
Definition: txdb.cpp:161
CCoinsViewDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: txdb.cpp:26
256-bit unsigned integer
Definition: uint256.h:531
bool BatchWrite(const std::map< uint256, CCoins > &mapCoins, const uint256 &hashBlock)
Definition: txdb.cpp:56
bool GetStats(CCoinsStats &stats)
Definition: txdb.cpp:110
bool SetBestBlock(const uint256 &hashBlock)
Definition: txdb.cpp:50
CCoinsView backed by the LevelDB coin database (chainstate/)
Definition: txdb.h:29
static const int64_t nMaxDbCache
Definition: txdb.h:24
bool WriteTxIndex(const std::vector< std::pair< uint256, CDiskTxPos > > &list)
Definition: txdb.cpp:165
bool WriteReindexing(bool fReindex)
Definition: txdb.cpp:94
bool HaveCoins(const uint256 &txid)
Definition: txdb.cpp:39
bool WriteFlag(const std::string &name, bool fValue)
Definition: txdb.cpp:172
uint256 GetBestBlock()
Definition: txdb.cpp:43
bool SetCoins(const uint256 &txid, const CCoins &coins)
Definition: txdb.cpp:33
bool WriteBestInvalidWork(const CBigNum &bnBestInvalidWork)
Definition: txdb.cpp:76