diff --git a/src/coins.h b/src/coins.h index d235a2844..bfb8233b5 100644 --- a/src/coins.h +++ b/src/coins.h @@ -207,11 +207,14 @@ public: CCoinsViewCache(CCoinsView *baseIn); // Standard CCoinsView methods - bool GetCoin(const COutPoint &outpoint, Coin &coin) const; - bool HaveCoin(const COutPoint &outpoint) const; - uint256 GetBestBlock() const; + bool GetCoin(const COutPoint &outpoint, Coin &coin) const override; + bool HaveCoin(const COutPoint &outpoint) const override; + uint256 GetBestBlock() const override; void SetBestBlock(const uint256 &hashBlock); - bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock); + bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) override; + CCoinsViewCursor* Cursor() const override { + throw std::logic_error("CCoinsViewCache cursor iteration not supported."); + } /** * Check if we have the given utxo already loaded in this cache. diff --git a/src/init.cpp b/src/init.cpp index 64173f7b0..577118ebd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -190,7 +190,6 @@ public: // Writes do not need similar protection, as failure to write is handled by the caller. }; -static CCoinsViewDB *pcoinsdbview = NULL; static CCoinsViewErrorCatcher *pcoinscatcher = NULL; static boost::scoped_ptr globalVerifyHandle; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 3623678ee..50e05124a 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -16,6 +16,7 @@ #include "rpc/server.h" #include "streams.h" #include "sync.h" +#include "txdb.h" #include "txmempool.h" #include "util.h" #include "utilstrencodings.h" @@ -646,7 +647,7 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp) CCoinsStats stats; FlushStateToDisk(); - if (GetUTXOStats(pcoinsTip, stats)) { + if (GetUTXOStats(pcoinsdbview, stats)) { ret.push_back(Pair("height", (int64_t)stats.nHeight)); ret.push_back(Pair("bestblock", stats.hashBlock.GetHex())); ret.push_back(Pair("transactions", (int64_t)stats.nTransactions)); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 7bdc0cfec..3d9c9e5b9 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -37,7 +37,7 @@ class CCoinsViewTest : public CCoinsView std::map map_; public: - bool GetCoin(const COutPoint& outpoint, Coin& coin) const + bool GetCoin(const COutPoint& outpoint, Coin& coin) const override { std::map::const_iterator it = map_.find(outpoint); if (it == map_.end()) { @@ -51,15 +51,15 @@ public: return true; } - bool HaveCoin(const COutPoint& outpoint) const + bool HaveCoin(const COutPoint& outpoint) const override { Coin coin; return GetCoin(outpoint, coin); } - uint256 GetBestBlock() const { return hashBestBlock_; } + uint256 GetBestBlock() const override { return hashBestBlock_; } - bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) + bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) override { for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end(); ) { if (it->second.flags & CCoinsCacheEntry::DIRTY) { diff --git a/src/validation.cpp b/src/validation.cpp index a3726d1a5..808184fed 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -184,6 +184,7 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc return chain.Genesis(); } +CCoinsViewDB *pcoinsdbview = NULL; CCoinsViewCache *pcoinsTip = NULL; CBlockTreeDB *pblocktree = NULL; diff --git a/src/validation.h b/src/validation.h index a318a87c2..50b5fcfb0 100644 --- a/src/validation.h +++ b/src/validation.h @@ -38,6 +38,7 @@ class CBlockIndex; class CBlockTreeDB; class CBloomFilter; class CChainParams; +class CCoinsViewDB; class CInv; class CConnman; class CScriptCheck; @@ -464,6 +465,9 @@ bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex); /** The currently-connected chain of blocks (protected by cs_main). */ extern CChain chainActive; +/** Global variable that points to the coins database (protected by cs_main) */ +extern CCoinsViewDB *pcoinsdbview; + /** Global variable that points to the active CCoinsView (protected by cs_main) */ extern CCoinsViewCache *pcoinsTip;