18 batch.
Erase(make_pair(
'c', hash));
20 batch.
Write(make_pair(
'c', hash), coins);
24 batch.
Write(
'B', hash);
31 return db.
Read(make_pair(
'c', txid), coins);
36 BatchWriteCoins(batch, txid, coins);
41 return db.
Exists(make_pair(
'c', txid));
46 if (!
db.
Read(
'B', hashBestChain))
53 BatchWriteHashBestChain(batch, hashBlock);
58 LogPrint(
"coindb",
"Committing %u changed transactions to coin database...\n", (
unsigned int)mapCoins.size());
61 for (std::map<uint256, CCoins>::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++)
62 BatchWriteCoins(batch, it->first, it->second);
64 BatchWriteHashBestChain(batch, hashBlock);
80 return Write(
'I', bnBestInvalidWork);
84 return Write(make_pair(
'f', nFile), info);
88 return Read(make_pair(
'f', nFile), info);
92 return Write(
'l', nFile);
97 return Write(
'R',
'1');
103 fReindexing =
Exists(
'R');
108 return Read(
'l', nFile);
113 pcursor->SeekToFirst();
118 int64_t nTotalAmount = 0;
119 while (pcursor->Valid()) {
120 boost::this_thread::interruption_point();
122 leveldb::Slice slKey = pcursor->key();
127 leveldb::Slice slValue = pcursor->value();
128 CDataStream ssValue(slValue.data(), slValue.data()+slValue.size(),
SER_DISK, CLIENT_VERSION);
134 ss <<
VARINT(coins.nVersion);
135 ss << (coins.fCoinBase ?
'c' :
'n');
136 ss <<
VARINT(coins.nHeight);
138 for (
unsigned int i=0; i<coins.vout.size(); i++) {
139 const CTxOut &out = coins.vout[i];
144 nTotalAmount += out.
nValue;
151 }
catch (std::exception &e) {
152 return error(
"%s : Deserialize or I/O error - %s", __func__, e.what());
163 return Read(make_pair(
't', txid), pos);
168 for (std::vector<std::pair<uint256,CDiskTxPos> >::const_iterator it=vect.begin(); it!=vect.end(); it++)
169 batch.
Write(make_pair(
't', it->first), it->second);
174 return Write(std::make_pair(
'F', name), fValue ?
'1' :
'0');
179 if (!
Read(std::make_pair(
'F', name), ch))
190 ssKeySet << make_pair(
'b',
uint256(0));
191 pcursor->Seek(ssKeySet.
str());
194 while (pcursor->Valid()) {
195 boost::this_thread::interruption_point();
197 leveldb::Slice slKey = pcursor->key();
202 leveldb::Slice slValue = pcursor->value();
203 CDataStream ssValue(slValue.data(), slValue.data()+slValue.size(),
SER_DISK, CLIENT_VERSION);
205 ssValue >> diskindex;
210 pindexNew->
nHeight = diskindex.nHeight;
211 pindexNew->
nFile = diskindex.nFile;
212 pindexNew->
nDataPos = diskindex.nDataPos;
213 pindexNew->
nUndoPos = diskindex.nUndoPos;
214 pindexNew->
nVersion = diskindex.nVersion;
216 pindexNew->
nTime = diskindex.nTime;
217 pindexNew->
nBits = diskindex.nBits;
218 pindexNew->
nNonce = diskindex.nNonce;
219 pindexNew->
nStatus = diskindex.nStatus;
220 pindexNew->
nTx = diskindex.nTx;
223 return error(
"LoadBlockIndex() : CheckIndex failed: %s", pindexNew->
ToString());
229 }
catch (std::exception &e) {
230 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)
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.
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()
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...
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)