Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
txdb.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2012 The Bitcoin developers
3 // Copyright (c) 2013 Feathercoin Developers
4 // Copyright (c) 2011-2013 PPCoin developers
5 // Copyright (c) 2013 Primecoin developers
6 // Distributed under the MIT/X11 software license, see the accompanying
7 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
8 #ifndef BITCOIN_TXDB_LEVELDB_H
9 #define BITCOIN_TXDB_LEVELDB_H
10 
11 #include "main.h"
12 #include "leveldb.h"
13 
15 class CCoinsViewDB : public CCoinsView
16 {
17 protected:
19 public:
20  CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
21 
22  bool GetCoins(const uint256 &txid, CCoins &coins);
23  bool SetCoins(const uint256 &txid, const CCoins &coins);
24  bool HaveCoins(const uint256 &txid);
26  bool SetBestBlock(CBlockIndex *pindex);
27  bool BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockIndex *pindex);
28  bool GetStats(CCoinsStats &stats);
29 };
30 
32 class CBlockTreeDB : public CLevelDB
33 {
34 public:
35  CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
36 private:
37  CBlockTreeDB(const CBlockTreeDB&);
38  void operator=(const CBlockTreeDB&);
39 public:
40  bool WriteBlockIndex(const CDiskBlockIndex& blockindex);
41  bool ReadBestInvalidWork(CBigNum& bnBestInvalidWork);
42  bool WriteBestInvalidWork(const CBigNum& bnBestInvalidWork);
43  bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo);
44  bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo);
45  bool ReadLastBlockFile(int &nFile);
46  bool WriteLastBlockFile(int nFile);
47  bool WriteReindexing(bool fReindex);
48  bool ReadReindexing(bool &fReindex);
49  bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
50  bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
51  bool WriteFlag(const std::string &name, bool fValue);
52  bool ReadFlag(const std::string &name, bool &fValue);
53  bool LoadBlockIndexGuts();
54 
55  // ppcoin sync checkpoint related data
56  bool ReadSyncCheckpoint(uint256& hashCheckpoint);
57  bool WriteSyncCheckpoint(uint256 hashCheckpoint);
58  bool ReadCheckpointPubKey(std::string& strPubKey);
59  bool WriteCheckpointPubKey(const std::string& strPubKey);
60 };
61 
62 #endif // BITCOIN_TXDB_LEVELDB_H
bool SetBestBlock(CBlockIndex *pindex)
Definition: txdb.cpp:53
bool BatchWrite(const std::map< uint256, CCoins > &mapCoins, CBlockIndex *pindex)
Definition: txdb.cpp:59
bool ReadCheckpointPubKey(std::string &strPubKey)
Definition: txdb.cpp:258
bool WriteSyncCheckpoint(uint256 hashCheckpoint)
Definition: txdb.cpp:253
bool ReadReindexing(bool &fReindex)
Definition: txdb.cpp:108
bool ReadLastBlockFile(int &nFile)
Definition: txdb.cpp:113
bool WriteBlockIndex(const CDiskBlockIndex &blockindex)
Definition: txdb.cpp:74
bool GetCoins(const uint256 &txid, CCoins &coins)
Definition: txdb.cpp:29
pruned version of CTransaction: only retains metadata and unspent transaction outputs ...
Definition: main.h:896
bool fReindex
Definition: main.cpp:50
bool LoadBlockIndexGuts()
Definition: txdb.cpp:191
CLevelDB db
Definition: txdb.h:18
void operator=(const CBlockTreeDB &)
Access to the block database (blocks/index/)
Definition: txdb.h:32
Abstract view on the open txout dataset.
Definition: main.h:2146
bool ReadBestInvalidWork(CBigNum &bnBestInvalidWork)
Definition: txdb.cpp:79
C++ wrapper for BIGNUM (OpenSSL bignum)
Definition: bignum.h:51
bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo)
Definition: txdb.cpp:89
Used to marshal pointers into hashes for db storage.
Definition: main.h:1840
bool ReadSyncCheckpoint(uint256 &hashCheckpoint)
Definition: txdb.cpp:248
bool WriteLastBlockFile(int nFile)
Definition: txdb.cpp:97
CBlockIndex * GetBestBlock()
Definition: txdb.cpp:43
bool ReadFlag(const std::string &name, bool &fValue)
Definition: txdb.cpp:183
CBlockTreeDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: txdb.cpp:71
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo)
Definition: txdb.cpp:93
bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos)
Definition: txdb.cpp:168
CCoinsViewDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
Definition: txdb.cpp:26
256-bit unsigned integer
Definition: uint256.h:537
bool GetStats(CCoinsStats &stats)
Definition: txdb.cpp:117
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: main.h:1626
CCoinsView backed by the LevelDB coin database (chainstate/)
Definition: txdb.h:15
Stats stats
Definition: db_bench.cc:291
bool WriteTxIndex(const std::vector< std::pair< uint256, CDiskTxPos > > &list)
Definition: txdb.cpp:172
bool WriteReindexing(bool fReindex)
Definition: txdb.cpp:101
bool HaveCoins(const uint256 &txid)
Definition: txdb.cpp:39
bool WriteFlag(const std::string &name, bool fValue)
Definition: txdb.cpp:179
bool WriteCheckpointPubKey(const std::string &strPubKey)
Definition: txdb.cpp:263
const char * name
Definition: testharness.cc:18
bool SetCoins(const uint256 &txid, const CCoins &coins)
Definition: txdb.cpp:33
bool WriteBestInvalidWork(const CBigNum &bnBestInvalidWork)
Definition: txdb.cpp:84