Anoncoin  0.9.4
P2P Digital Currency
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 // Copyright (c) 2013-2014 The Anoncoin Core developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef ANONCOIN_TXDB_LEVELDB_H
8 #define ANONCOIN_TXDB_LEVELDB_H
9 
10 #include "leveldbwrapper.h"
11 #include "main.h"
12 
13 #include <map>
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
18 class CBigNum;
19 class CCoins;
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 ? 4096 : 1024;
26 // min. -dbcache in (MiB)
27 static const int64_t nMinDbCache = 4;
28 
30 class CCoinsViewDB : public CCoinsView
31 {
32 protected:
34 public:
35  CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
36 
37  bool GetCoins(const uint256 &txid, CCoins &coins);
38  bool SetCoins(const uint256 &txid, const CCoins &coins);
39  bool HaveCoins(const uint256 &txid);
41  bool SetBestBlock(const uint256 &hashBlock);
42  bool BatchWrite(const std::map<uint256, CCoins> &mapCoins, const uint256 &hashBlock);
43  bool GetStats(CCoinsStats &stats);
44 };
45 
48 {
49 public:
50  CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
51 private:
52  CBlockTreeDB(const CBlockTreeDB&);
53  void operator=(const CBlockTreeDB&);
54 public:
55  bool WriteBlockIndex(const CDiskBlockIndex& blockindex);
56  bool WriteBestInvalidWork(const CBigNum& bnBestInvalidWork);
57  bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo);
58  bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo);
59  bool ReadLastBlockFile(int &nFile);
60  bool WriteLastBlockFile(int nFile);
61  bool WriteReindexing(bool fReindex);
62  bool ReadReindexing(bool &fReindex);
63  bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
64  bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
65  bool WriteFlag(const std::string &name, bool fValue);
66  bool ReadFlag(const std::string &name, bool &fValue);
67  bool LoadBlockIndexGuts();
68 };
69 
70 #endif // ANONCOIN_TXDB_LEVELDB_H
bool ReadReindexing(bool &fReindex)
Definition: txdb.cpp:102
bool ReadLastBlockFile(int &nFile)
Definition: txdb.cpp:107
bool WriteBlockIndex(const CDiskBlockIndex &blockindex)
Definition: txdb.cpp:72
bool GetCoins(const uint256 &txid, CCoins &coins)
Definition: txdb.cpp:30
pruned version of CTransaction: only retains metadata and unspent transaction outputs ...
Definition: coins.h:69
bool fReindex
Definition: main.cpp:48
bool LoadBlockIndexGuts()
Definition: txdb.cpp:185
void operator=(const CBlockTreeDB &)
Access to the block database (blocks/index/)
Definition: txdb.h:47
Abstract view on the open txout dataset.
Definition: coins.h:259
CLevelDBWrapper db
Definition: txdb.h:33
C++ wrapper for BIGNUM (OpenSSL bignum)
Definition: bignum.h:57
bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo)
Definition: txdb.cpp:83
Used to marshal pointers into hashes for db storage.
Definition: main.h:883
bool WriteLastBlockFile(int nFile)
Definition: txdb.cpp:91
bool ReadFlag(const std::string &name, bool &fValue)
Definition: txdb.cpp:177
CBlockTreeDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: txdb.cpp:69
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo)
Definition: txdb.cpp:87
bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos)
Definition: txdb.cpp:162
CCoinsViewDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: txdb.cpp:27
256-bit unsigned integer
Definition: uint256.h:532
bool BatchWrite(const std::map< uint256, CCoins > &mapCoins, const uint256 &hashBlock)
Definition: txdb.cpp:57
bool GetStats(CCoinsStats &stats)
Definition: txdb.cpp:111
bool SetBestBlock(const uint256 &hashBlock)
Definition: txdb.cpp:51
CCoinsView backed by the LevelDB coin database (chainstate/)
Definition: txdb.h:30
bool WriteTxIndex(const std::vector< std::pair< uint256, CDiskTxPos > > &list)
Definition: txdb.cpp:166
bool WriteReindexing(bool fReindex)
Definition: txdb.cpp:95
bool HaveCoins(const uint256 &txid)
Definition: txdb.cpp:40
bool WriteFlag(const std::string &name, bool fValue)
Definition: txdb.cpp:173
uint256 GetBestBlock()
Definition: txdb.cpp:44
bool SetCoins(const uint256 &txid, const CCoins &coins)
Definition: txdb.cpp:34
bool WriteBestInvalidWork(const CBigNum &bnBestInvalidWork)
Definition: txdb.cpp:77