diff options
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r-- | src/txdb.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp index a3a9b31534..d4c6007558 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -28,7 +28,7 @@ void static BatchWriteHashBestChain(CLevelDBBatch &batch, const uint256 &hash) { CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe) { } -bool CCoinsViewDB::GetCoins(const uint256 &txid, CCoins &coins) { +bool CCoinsViewDB::GetCoins(const uint256 &txid, CCoins &coins) const { return db.Read(make_pair('c', txid), coins); } @@ -38,11 +38,11 @@ bool CCoinsViewDB::SetCoins(const uint256 &txid, const CCoins &coins) { return db.WriteBatch(batch); } -bool CCoinsViewDB::HaveCoins(const uint256 &txid) { +bool CCoinsViewDB::HaveCoins(const uint256 &txid) const { return db.Exists(make_pair('c', txid)); } -uint256 CCoinsViewDB::GetBestBlock() { +uint256 CCoinsViewDB::GetBestBlock() const { uint256 hashBestChain; if (!db.Read('B', hashBestChain)) return uint256(0); @@ -106,8 +106,11 @@ bool CBlockTreeDB::ReadLastBlockFile(int &nFile) { return Read('l', nFile); } -bool CCoinsViewDB::GetStats(CCoinsStats &stats) { - boost::scoped_ptr<leveldb::Iterator> pcursor(db.NewIterator()); +bool CCoinsViewDB::GetStats(CCoinsStats &stats) const { + /* It seems that there are no "const iterators" for LevelDB. Since we + only need read operations on it, use a const-cast to get around + that restriction. */ + leveldb::Iterator *pcursor = const_cast<CLevelDBWrapper*>(&db)->NewIterator(); pcursor->SeekToFirst(); CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); |