diff options
author | Daniel Kraft <d@domob.eu> | 2014-07-19 16:42:48 +0200 |
---|---|---|
committer | Daniel Kraft <d@domob.eu> | 2014-08-26 11:29:18 +0200 |
commit | a3dc587a62f5d12aea1ff8139198bf0441535c5f (patch) | |
tree | 4759437af72c07a075c6819bb5c2435d7350f0d8 /src/txdb.cpp | |
parent | ffb4c210bc0b78bd8cbccdb7ccb80dde918a01b0 (diff) |
Make appropriate getter-routines "const" in CCoinsView.
Mark the "Get"/"Have" routines in CCoinsView and subclasses as "const".
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 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); |