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
This commit is contained in:
parent
9ad56fe18a
commit
4f807422fa
11
src/coins.h
11
src/coins.h
@ -207,11 +207,14 @@ public:
|
|||||||
CCoinsViewCache(CCoinsView *baseIn);
|
CCoinsViewCache(CCoinsView *baseIn);
|
||||||
|
|
||||||
// Standard CCoinsView methods
|
// Standard CCoinsView methods
|
||||||
bool GetCoin(const COutPoint &outpoint, Coin &coin) const;
|
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
|
||||||
bool HaveCoin(const COutPoint &outpoint) const;
|
bool HaveCoin(const COutPoint &outpoint) const override;
|
||||||
uint256 GetBestBlock() const;
|
uint256 GetBestBlock() const override;
|
||||||
void SetBestBlock(const uint256 &hashBlock);
|
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.
|
* Check if we have the given utxo already loaded in this cache.
|
||||||
|
@ -190,7 +190,6 @@ public:
|
|||||||
// Writes do not need similar protection, as failure to write is handled by the caller.
|
// Writes do not need similar protection, as failure to write is handled by the caller.
|
||||||
};
|
};
|
||||||
|
|
||||||
static CCoinsViewDB *pcoinsdbview = NULL;
|
|
||||||
static CCoinsViewErrorCatcher *pcoinscatcher = NULL;
|
static CCoinsViewErrorCatcher *pcoinscatcher = NULL;
|
||||||
static boost::scoped_ptr<ECCVerifyHandle> globalVerifyHandle;
|
static boost::scoped_ptr<ECCVerifyHandle> globalVerifyHandle;
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "rpc/server.h"
|
#include "rpc/server.h"
|
||||||
#include "streams.h"
|
#include "streams.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
|
#include "txdb.h"
|
||||||
#include "txmempool.h"
|
#include "txmempool.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "utilstrencodings.h"
|
#include "utilstrencodings.h"
|
||||||
@ -646,7 +647,7 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
CCoinsStats stats;
|
CCoinsStats stats;
|
||||||
FlushStateToDisk();
|
FlushStateToDisk();
|
||||||
if (GetUTXOStats(pcoinsTip, stats)) {
|
if (GetUTXOStats(pcoinsdbview, stats)) {
|
||||||
ret.push_back(Pair("height", (int64_t)stats.nHeight));
|
ret.push_back(Pair("height", (int64_t)stats.nHeight));
|
||||||
ret.push_back(Pair("bestblock", stats.hashBlock.GetHex()));
|
ret.push_back(Pair("bestblock", stats.hashBlock.GetHex()));
|
||||||
ret.push_back(Pair("transactions", (int64_t)stats.nTransactions));
|
ret.push_back(Pair("transactions", (int64_t)stats.nTransactions));
|
||||||
|
@ -37,7 +37,7 @@ class CCoinsViewTest : public CCoinsView
|
|||||||
std::map<COutPoint, Coin> map_;
|
std::map<COutPoint, Coin> map_;
|
||||||
|
|
||||||
public:
|
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);
|
std::map<COutPoint, Coin>::const_iterator it = map_.find(outpoint);
|
||||||
if (it == map_.end()) {
|
if (it == map_.end()) {
|
||||||
@ -51,15 +51,15 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HaveCoin(const COutPoint& outpoint) const
|
bool HaveCoin(const COutPoint& outpoint) const override
|
||||||
{
|
{
|
||||||
Coin coin;
|
Coin coin;
|
||||||
return GetCoin(outpoint, 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(); ) {
|
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end(); ) {
|
||||||
if (it->second.flags & CCoinsCacheEntry::DIRTY) {
|
if (it->second.flags & CCoinsCacheEntry::DIRTY) {
|
||||||
|
@ -184,6 +184,7 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
|
|||||||
return chain.Genesis();
|
return chain.Genesis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCoinsViewDB *pcoinsdbview = NULL;
|
||||||
CCoinsViewCache *pcoinsTip = NULL;
|
CCoinsViewCache *pcoinsTip = NULL;
|
||||||
CBlockTreeDB *pblocktree = NULL;
|
CBlockTreeDB *pblocktree = NULL;
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ class CBlockIndex;
|
|||||||
class CBlockTreeDB;
|
class CBlockTreeDB;
|
||||||
class CBloomFilter;
|
class CBloomFilter;
|
||||||
class CChainParams;
|
class CChainParams;
|
||||||
|
class CCoinsViewDB;
|
||||||
class CInv;
|
class CInv;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CScriptCheck;
|
class CScriptCheck;
|
||||||
@ -464,6 +465,9 @@ bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex);
|
|||||||
/** The currently-connected chain of blocks (protected by cs_main). */
|
/** The currently-connected chain of blocks (protected by cs_main). */
|
||||||
extern CChain chainActive;
|
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) */
|
/** Global variable that points to the active CCoinsView (protected by cs_main) */
|
||||||
extern CCoinsViewCache *pcoinsTip;
|
extern CCoinsViewCache *pcoinsTip;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user