aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-06-12 16:19:08 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-06-12 16:29:59 +0200
commitb7296bcea0c942abefcb3243e3e558b95933c082 (patch)
tree7d6e93af29fbb934ec8685ceaf473225f5d5f89f /src
parentad1a13e85c1eb638f32509993ce319356ba2b9e0 (diff)
parent3ff1fa8c4a6198ebc277bbf814b4e07bf78eb98a (diff)
Merge #10550: Don't return stale data from CCoinsViewCache::Cursor()
3ff1fa8 Use override keyword on CCoinsView overrides (Russell Yanofsky) 24e44c3 Don't return stale data from CCoinsViewCache::Cursor() (Russell Yanofsky) Tree-SHA512: 08699dae0925ffb9c018f02612ac6b7eaf73ec331e2f4f934f1fe25a2ce120735fa38596926e924897c203f7470e99f0a99cf70d2ce31ff428b105e16583a861
Diffstat (limited to 'src')
-rw-r--r--src/coins.h11
-rw-r--r--src/init.cpp1
-rw-r--r--src/rpc/blockchain.cpp3
-rw-r--r--src/test/coins_tests.cpp8
-rw-r--r--src/validation.cpp1
-rw-r--r--src/validation.h4
6 files changed, 18 insertions, 10 deletions
diff --git a/src/coins.h b/src/coins.h
index 22b1f57b9e..dc3210b8ac 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -206,11 +206,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 9aa8730cda..56d0bd9b0e 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -161,7 +161,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 std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index b66c1c2b64..388472f076 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -19,6 +19,7 @@
#include "rpc/server.h"
#include "streams.h"
#include "sync.h"
+#include "txdb.h"
#include "txmempool.h"
#include "util.h"
#include "utilstrencodings.h"
@@ -921,7 +922,7 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request)
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 a72975d6e4..4fd3ff9cf1 100644
--- a/src/test/coins_tests.cpp
+++ b/src/test/coins_tests.cpp
@@ -36,7 +36,7 @@ class CCoinsViewTest : public CCoinsView
std::map<COutPoint, Coin> map_;
public:
- bool GetCoin(const COutPoint& outpoint, Coin& coin) const
+ bool GetCoin(const COutPoint& outpoint, Coin& coin) const override
{
std::map<COutPoint, Coin>::const_iterator it = map_.find(outpoint);
if (it == map_.end()) {
@@ -50,15 +50,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 997deb9a14..9350735bab 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -174,6 +174,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 0f410530fb..b8d39c4b41 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -34,6 +34,7 @@ class CBlockIndex;
class CBlockTreeDB;
class CBloomFilter;
class CChainParams;
+class CCoinsViewDB;
class CInv;
class CConnman;
class CScriptCheck;
@@ -440,6 +441,9 @@ bool ResetBlockFailureFlags(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;