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);
35 BatchWriteCoins(batch, txid, coins);
40 return db.
Exists(make_pair(
'c', txid));
45 if (!
db.
Read(
'B', hashBestChain))
47 std::map<uint256, CBlockIndex*>::iterator it =
mapBlockIndex.find(hashBestChain);
60 printf(
"Committing %u changed transactions to coin database...\n", (
unsigned int)mapCoins.size());
63 for (std::map<uint256, CCoins>::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++)
64 BatchWriteCoins(batch, it->first, it->second);
81 return Read(
'I', bnBestInvalidWork);
86 return Write(
'I', bnBestInvalidWork);
90 return Write(make_pair(
'f', nFile), info);
94 return Read(make_pair(
'f', nFile), info);
98 return Write(
'l', nFile);
103 return Write(
'R',
'1');
109 fReindexing =
Exists(
'R');
114 return Read(
'l', nFile);
124 int64 nTotalAmount = 0;
125 while (pcursor->
Valid()) {
126 boost::this_thread::interruption_point();
140 ss <<
VARINT(coins.nVersion);
141 ss << (coins.fCoinBase ?
'c' :
'n');
142 ss <<
VARINT(coins.nHeight);
144 for (
unsigned int i=0; i<coins.vout.size(); i++) {
145 const CTxOut &out = coins.vout[i];
150 nTotalAmount += out.
nValue;
157 }
catch (std::exception &e) {
158 return error(
"%s() : deserialize error", __PRETTY_FUNCTION__);
169 return Read(make_pair(
't', txid), pos);
174 for (std::vector<std::pair<uint256,CDiskTxPos> >::const_iterator it=vect.begin(); it!=vect.end(); it++)
175 batch.
Write(make_pair(
't', it->first), it->second);
180 return Write(std::make_pair(
'F', name), fValue ?
'1' :
'0');
185 if (!
Read(std::make_pair(
'F', name), ch))
196 ssKeySet << make_pair(
'b',
uint256(0));
200 while (pcursor->
Valid()) {
201 boost::this_thread::interruption_point();
211 ssValue >> diskindex;
216 pindexNew->
nHeight = diskindex.nHeight;
217 pindexNew->
nFile = diskindex.nFile;
218 pindexNew->
nDataPos = diskindex.nDataPos;
219 pindexNew->
nUndoPos = diskindex.nUndoPos;
220 pindexNew->
nVersion = diskindex.nVersion;
222 pindexNew->
nTime = diskindex.nTime;
223 pindexNew->
nBits = diskindex.nBits;
224 pindexNew->
nNonce = diskindex.nNonce;
225 pindexNew->
nStatus = diskindex.nStatus;
226 pindexNew->
nTx = diskindex.nTx;
233 return error(
"LoadBlockIndex() : CheckIndex failed: %s", pindexNew->
ToString().c_str());
239 }
catch (std::exception &e) {
240 return error(
"%s() : deserialize error", __PRETTY_FUNCTION__);
250 return Read(
string(
"hashSyncCheckpoint"), hashCheckpoint);
255 return Write(
string(
"hashSyncCheckpoint"), hashCheckpoint);
260 return Read(
string(
"strCheckpointPubKey"), strPubKey);
265 return Write(
string(
"strCheckpointPubKey"), strPubKey);
bool Read(const K &key, V &value)
bool error(const char *format,...)
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
bool SetBestBlock(CBlockIndex *pindex)
bool Write(const K &key, const V &value, bool fSync=false)
bool BatchWrite(const std::map< uint256, CCoins > &mapCoins, CBlockIndex *pindex)
bool ReadCheckpointPubKey(std::string &strPubKey)
const char * data() const
bool WriteSyncCheckpoint(uint256 hashCheckpoint)
bool ReadReindexing(bool &fReindex)
bool ReadLastBlockFile(int &nFile)
bool WriteBatch(CLevelDBBatch &batch, bool fSync=false)
std::string ToString() const
bool WriteBlockIndex(const CDiskBlockIndex &blockindex)
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 LoadBlockIndexGuts()
bool Exists(const K &key)
uint256 hashGenesisBlock("0x12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2")
virtual Slice value() const =0
bool Erase(const K &key, bool fSync=false)
bool ReadBestInvalidWork(CBigNum &bnBestInvalidWork)
C++ wrapper for BIGNUM (OpenSSL bignum)
virtual void Seek(const Slice &target)=0
bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo)
virtual void SeekToFirst()=0
An output of a transaction.
Used to marshal pointers into hashes for db storage.
bool ReadSyncCheckpoint(uint256 &hashCheckpoint)
bool WriteLastBlockFile(int nFile)
CBlockIndex * GetBestBlock()
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)
CBlockIndex * pindexGenesisBlock
bool GetStats(CCoinsStats &stats)
The block chain is a tree shaped structure starting with the genesis block at the root...
leveldb::Iterator * NewIterator()
virtual bool Valid() const =0
bool WriteTxIndex(const std::vector< std::pair< uint256, CDiskTxPos > > &list)
uint64 nTransactionOutputs
bool WriteReindexing(bool fReindex)
bool HaveCoins(const uint256 &txid)
virtual Slice key() const =0
bool WriteFlag(const std::string &name, bool fValue)
bool WriteCheckpointPubKey(const std::string &strPubKey)
map< uint256, CBlockIndex * > mapBlockIndex
uint256 GetBlockHash() const
bool SetCoins(const uint256 &txid, const CCoins &coins)
bool WriteBestInvalidWork(const CBigNum &bnBestInvalidWork)