]> Git Repo - VerusCoin.git/blame - src/txdb.h
Merge pull request #42 from jl777/dev
[VerusCoin.git] / src / txdb.h
CommitLineData
2d8a4829 1// Copyright (c) 2009-2010 Satoshi Nakamoto
f914f1a7 2// Copyright (c) 2009-2014 The Bitcoin Core developers
fa94b9d5 3// Distributed under the MIT software license, see the accompanying
2d8a4829 4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
51ed9ec9 5
84738627
PJ
6#ifndef BITCOIN_TXDB_H
7#define BITCOIN_TXDB_H
2d8a4829 8
8a893c94 9#include "coins.h"
b64187d0 10#include "leveldbwrapper.h"
51ed9ec9
BD
11
12#include <map>
13#include <string>
14#include <utility>
15#include <vector>
16
8a893c94
JT
17class CBlockFileInfo;
18class CBlockIndex;
63e4c9cd 19struct CDiskTxPos;
8b78a819
T
20struct CAddressUnspentKey;
21struct CAddressUnspentValue;
22struct CAddressIndexKey;
23struct CAddressIndexIteratorKey;
24struct CAddressIndexIteratorHeightKey;
25struct CTimestampIndexKey;
26struct CTimestampIndexIteratorKey;
27struct CTimestampBlockIndexKey;
28struct CTimestampBlockIndexValue;
29struct CSpentIndexKey;
30struct CSpentIndexValue;
51ed9ec9 31class uint256;
2d8a4829 32
fa94b9d5 33//! -dbcache default (MiB)
5befbed4
S
34static const int64_t nDefaultDbCache = 450;
35//! max. -dbcache (MiB)
b3ed4236 36static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
fa94b9d5 37//! min. -dbcache in (MiB)
ad54a9b8 38static const int64_t nMinDbCache = 4;
82e96006 39
8fdc94cc 40/** CCoinsView backed by the LevelDB coin database (chainstate/) */
4ca60bba
PW
41class CCoinsViewDB : public CCoinsView
42{
43protected:
b64187d0 44 CLevelDBWrapper db;
c66c731a 45 CCoinsViewDB(std::string dbName, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
4ca60bba 46public:
7fea4846 47 CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
4ca60bba 48
434f3284 49 bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const;
b78daf7d 50 bool GetNullifier(const uint256 &nf) const;
a3dc587a 51 bool GetCoins(const uint256 &txid, CCoins &coins) const;
a3dc587a
DK
52 bool HaveCoins(const uint256 &txid) const;
53 uint256 GetBestBlock() const;
9f25631d
SB
54 uint256 GetBestAnchor() const;
55 bool BatchWrite(CCoinsMap &mapCoins,
56 const uint256 &hashBlock,
57 const uint256 &hashAnchor,
45d6bee9 58 CAnchorsMap &mapAnchors,
bb64be52 59 CNullifiersMap &mapNullifiers);
a3dc587a 60 bool GetStats(CCoinsStats &stats) const;
4ca60bba
PW
61};
62
8fdc94cc 63/** Access to the block database (blocks/index/) */
b64187d0 64class CBlockTreeDB : public CLevelDBWrapper
4ca60bba
PW
65{
66public:
8b78a819 67 CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false, bool compression = true, int maxOpenFiles = 1000);
4ca60bba
PW
68private:
69 CBlockTreeDB(const CBlockTreeDB&);
70 void operator=(const CBlockTreeDB&);
71public:
63d1ae55 72 bool WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo);
4ca60bba 73 bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo);
4ca60bba 74 bool ReadLastBlockFile(int &nFile);
7fea4846
PW
75 bool WriteReindexing(bool fReindex);
76 bool ReadReindexing(bool &fReindex);
2d1fa42e
PW
77 bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
78 bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
8b78a819
T
79 bool ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value);
80 bool UpdateSpentIndex(const std::vector<std::pair<CSpentIndexKey, CSpentIndexValue> >&vect);
81 bool UpdateAddressUnspentIndex(const std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue > >&vect);
82 bool ReadAddressUnspentIndex(uint160 addressHash, int type,
83 std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &vect);
84 bool WriteAddressIndex(const std::vector<std::pair<CAddressIndexKey, CAmount> > &vect);
85 bool EraseAddressIndex(const std::vector<std::pair<CAddressIndexKey, CAmount> > &vect);
86 bool ReadAddressIndex(uint160 addressHash, int type,
87 std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,
88 int start = 0, int end = 0);
89 bool WriteTimestampIndex(const CTimestampIndexKey &timestampIndex);
90 bool ReadTimestampIndex(const unsigned int &high, const unsigned int &low, const bool fActiveOnly, std::vector<std::pair<uint256, unsigned int> > &vect);
91 bool WriteTimestampBlockIndex(const CTimestampBlockIndexKey &blockhashIndex, const CTimestampBlockIndexValue &logicalts);
92 bool ReadTimestampBlockIndex(const uint256 &hash, unsigned int &logicalTS);
2d1fa42e
PW
93 bool WriteFlag(const std::string &name, bool fValue);
94 bool ReadFlag(const std::string &name, bool &fValue);
4ca60bba 95 bool LoadBlockIndexGuts();
8b78a819 96 bool blockOnchainActive(const uint256 &hash);
78a6f704 97 int64_t Snapshot();
4ca60bba
PW
98};
99
84738627 100#endif // BITCOIN_TXDB_H
This page took 0.216734 seconds and 4 git commands to generate.