Merge pull request #361 from svost/master
[novacoin.git] / src / txdb-bdb.h
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2012 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
5
6 #ifndef BITCOIN_TXDB_BDB_H
7 #define BITCOIN_TXDB_BDB_H
8
9
10 /** Access to the transaction database (blkindex.dat) */
11 class CTxDB : public CDB
12 {
13 public:
14     CTxDB(const char* pszMode="r+") : CDB("blkindex.dat", pszMode) { }
15 private:
16     CTxDB(const CTxDB&);
17     void operator=(const CTxDB&);
18 public:
19
20     bool ReadTxIndex(uint256 hash, CTxIndex& txindex);
21     bool UpdateTxIndex(uint256 hash, const CTxIndex& txindex);
22     bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight);
23     bool EraseTxIndex(const CTransaction& tx);
24     bool ContainsTx(uint256 hash);
25     bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex);
26     bool ReadDiskTx(uint256 hash, CTransaction& tx);
27     bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex);
28     bool ReadDiskTx(COutPoint outpoint, CTransaction& tx);
29     bool WriteBlockIndex(const CDiskBlockIndex& blockindex);
30     bool ReadHashBestChain(uint256& hashBestChain);
31     bool WriteHashBestChain(uint256 hashBestChain);
32     bool ReadBestInvalidTrust(CBigNum& bnBestInvalidTrust);
33     bool WriteBestInvalidTrust(CBigNum bnBestInvalidTrust);
34     bool ReadSyncCheckpoint(uint256& hashCheckpoint);
35     bool WriteSyncCheckpoint(uint256 hashCheckpoint);
36     bool ReadCheckpointPubKey(std::string& strPubKey);
37     bool WriteCheckpointPubKey(const std::string& strPubKey);
38     bool ReadModifierUpgradeTime(unsigned int& nUpgradeTime);
39     bool WriteModifierUpgradeTime(const unsigned int& nUpgradeTime);
40     bool LoadBlockIndex();
41 private:
42     bool LoadBlockIndexGuts();
43 };
44
45 #endif