aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-08-26 16:47:44 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-08-26 16:49:02 +0200
commit790911ff0a659becd983afd5309b2c16401ba28d (patch)
tree0e8013882018d752e12b86de7f854cfb30143d19 /src/txdb.cpp
parent0d763fc9e148f753cff19daea23866f139ad0a7f (diff)
parentd0867acb0e07ac63f03dcc555387f24322e8799e (diff)
Merge pull request #4561
d0867ac Use const CCoinsView's at some places. (Daniel Kraft) a3dc587 Make appropriate getter-routines "const" in CCoinsView. (Daniel Kraft) ffb4c21 Mark LevelDB "Read" and "Exists" functions as const. (Daniel Kraft)
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r--src/txdb.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 7c0683aaf3..2349514def 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -27,7 +27,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);
}
@@ -37,11 +37,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);
@@ -105,8 +105,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);