17 batch.
Erase(make_pair(
'c', hash));
19 batch.
Write(make_pair(
'c', hash), coins);
23 batch.
Write(
'B', hash);
30 return db.
Read(make_pair(
'c', txid), coins);
40 return db.
Exists(make_pair(
'c', txid));
45 if (!
db.
Read(
'B', hashBestChain))
57 LogPrint(
"coindb",
"Committing %u changed transactions to coin database...\n", (
unsigned int)mapCoins.size());
60 for (std::map<uint256, CCoins>::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++)
79 return Write(
'I', bnBestInvalidWork);
83 return Write(make_pair(
'f', nFile), info);
87 return Read(make_pair(
'f', nFile), info);
91 return Write(
'l', nFile);
96 return Write(
'R',
'1');
102 fReindexing =
Exists(
'R');
107 return Read(
'l', nFile);
112 pcursor->SeekToFirst();
117 int64_t nTotalAmount = 0;
118 while (pcursor->Valid()) {
119 boost::this_thread::interruption_point();
121 leveldb::Slice slKey = pcursor->key();
126 leveldb::Slice slValue = pcursor->value();
133 ss <<
VARINT(coins.nVersion);
134 ss << (coins.fCoinBase ?
'c' :
'n');
135 ss <<
VARINT(coins.nHeight);
137 for (
unsigned int i=0; i<coins.vout.size(); i++) {
138 const CTxOut &out = coins.vout[i];
143 nTotalAmount += out.
nValue;
150 }
catch (std::exception &e) {
151 return error(
"%s : Deserialize or I/O error - %s", __func__, e.what());
162 return Read(make_pair(
't', txid), pos);
167 for (std::vector<std::pair<uint256,CDiskTxPos> >::const_iterator it=vect.begin(); it!=vect.end(); it++)
168 batch.
Write(make_pair(
't', it->first), it->second);
173 return Write(std::make_pair(
'F', name), fValue ?
'1' :
'0');
178 if (!
Read(std::make_pair(
'F', name), ch))
189 ssKeySet << make_pair(
'b',
uint256(0));
190 pcursor->Seek(ssKeySet.
str());
193 while (pcursor->Valid()) {
194 boost::this_thread::interruption_point();
196 leveldb::Slice slKey = pcursor->key();
201 leveldb::Slice slValue = pcursor->value();
204 ssValue >> diskindex;
209 pindexNew->
nHeight = diskindex.nHeight;
210 pindexNew->
nFile = diskindex.nFile;
211 pindexNew->
nDataPos = diskindex.nDataPos;
212 pindexNew->
nUndoPos = diskindex.nUndoPos;
213 pindexNew->
nVersion = diskindex.nVersion;
215 pindexNew->
nTime = diskindex.nTime;
216 pindexNew->
nBits = diskindex.nBits;
217 pindexNew->
nNonce = diskindex.nNonce;
218 pindexNew->
nStatus = diskindex.nStatus;
219 pindexNew->
nTx = diskindex.nTx;
222 return error(
"LoadBlockIndex() : CheckIndex failed: %s", pindexNew->
ToString());
228 }
catch (std::exception &e) {
229 return error(
"%s : Deserialize or I/O error - %s", __func__, e.what());
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
uint64_t nTransactionOutputs
bool Erase(const K &key, bool fSync=false)
bool ReadReindexing(bool &fReindex)
bool ReadLastBlockFile(int &nFile)
static const int CLIENT_VERSION
std::string ToString() const
bool WriteBlockIndex(const CDiskBlockIndex &blockindex)
bool Write(const K &key, const V &value, bool fSync=false)
bool GetCoins(const uint256 &txid, CCoins &coins)
Double ended buffer combining vector and stream-like interfaces.
static void BatchWriteHashBestChain(CLevelDBBatch &batch, const uint256 &hash)
void Write(const K &key, const V &value)
pruned version of CTransaction: only retains metadata and unspent transaction outputs ...
bool Exists(const K &key)
bool LoadBlockIndexGuts()
static void BatchWriteCoins(CLevelDBBatch &batch, const uint256 &hash, const CCoins &coins)
static int LogPrint(const char *category, const char *format)
static bool error(const char *format)
C++ wrapper for BIGNUM (OpenSSL bignum)
bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo)
An output of a transaction.
Used to marshal pointers into hashes for db storage.
bool WriteLastBlockFile(int nFile)
bool Read(const K &key, V &value)
bool ReadFlag(const std::string &name, bool &fValue)
CBlockTreeDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo)
CBlockIndex * InsertBlockIndex(uint256 hash)
Create a new block index entry for a given block hash.
bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos)
CCoinsViewDB(size_t nCacheSize, bool fMemory=false, bool fWipe=false)
bool BatchWrite(const std::map< uint256, CCoins > &mapCoins, const uint256 &hashBlock)
bool GetStats(CCoinsStats &stats)
bool SetBestBlock(const uint256 &hashBlock)
bool WriteBatch(CLevelDBBatch &batch, bool fSync=false)
The block chain is a tree shaped structure starting with the genesis block at the root...
static const int PROTOCOL_VERSION
bool WriteTxIndex(const std::vector< std::pair< uint256, CDiskTxPos > > &list)
bool WriteReindexing(bool fReindex)
bool HaveCoins(const uint256 &txid)
bool WriteFlag(const std::string &name, bool fValue)
leveldb::Iterator * NewIterator()
map< uint256, CBlockIndex * > mapBlockIndex
uint256 GetBlockHash() const
bool SetCoins(const uint256 &txid, const CCoins &coins)
bool WriteBestInvalidWork(const CBigNum &bnBestInvalidWork)