Get rid of the dummy CCoinsViewCache constructor arg
This commit is contained in:
parent
ed27e53c9b
commit
7c70438dc6
14 changed files with 24 additions and 24 deletions
|
@ -340,7 +340,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
|
||||||
CMutableTransaction mergedTx(txVariants[0]);
|
CMutableTransaction mergedTx(txVariants[0]);
|
||||||
bool fComplete = true;
|
bool fComplete = true;
|
||||||
CCoinsView viewDummy;
|
CCoinsView viewDummy;
|
||||||
CCoinsViewCache view(viewDummy);
|
CCoinsViewCache view(&viewDummy);
|
||||||
|
|
||||||
if (!registers.count("privatekeys"))
|
if (!registers.count("privatekeys"))
|
||||||
throw runtime_error("privatekeys register variable must be set.");
|
throw runtime_error("privatekeys register variable must be set.");
|
||||||
|
|
|
@ -59,7 +59,7 @@ bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { ret
|
||||||
bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
|
bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
|
||||||
|
|
||||||
|
|
||||||
CCoinsViewBacked::CCoinsViewBacked(CCoinsView &viewIn) : base(&viewIn) { }
|
CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) { }
|
||||||
bool CCoinsViewBacked::GetCoins(const uint256 &txid, CCoins &coins) const { return base->GetCoins(txid, coins); }
|
bool CCoinsViewBacked::GetCoins(const uint256 &txid, CCoins &coins) const { return base->GetCoins(txid, coins); }
|
||||||
bool CCoinsViewBacked::HaveCoins(const uint256 &txid) const { return base->HaveCoins(txid); }
|
bool CCoinsViewBacked::HaveCoins(const uint256 &txid) const { return base->HaveCoins(txid); }
|
||||||
uint256 CCoinsViewBacked::GetBestBlock() const { return base->GetBestBlock(); }
|
uint256 CCoinsViewBacked::GetBestBlock() const { return base->GetBestBlock(); }
|
||||||
|
@ -69,7 +69,7 @@ bool CCoinsViewBacked::GetStats(CCoinsStats &stats) const { return base->GetStat
|
||||||
|
|
||||||
CCoinsKeyHasher::CCoinsKeyHasher() : salt(GetRandHash()) {}
|
CCoinsKeyHasher::CCoinsKeyHasher() : salt(GetRandHash()) {}
|
||||||
|
|
||||||
CCoinsViewCache::CCoinsViewCache(CCoinsView &baseIn, bool fDummy) : CCoinsViewBacked(baseIn), hasModifier(false), hashBlock(0) { }
|
CCoinsViewCache::CCoinsViewCache(CCoinsView *baseIn) : CCoinsViewBacked(baseIn), hasModifier(false), hashBlock(0) { }
|
||||||
|
|
||||||
CCoinsViewCache::~CCoinsViewCache()
|
CCoinsViewCache::~CCoinsViewCache()
|
||||||
{
|
{
|
||||||
|
|
|
@ -333,7 +333,7 @@ protected:
|
||||||
CCoinsView *base;
|
CCoinsView *base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCoinsViewBacked(CCoinsView &viewIn);
|
CCoinsViewBacked(CCoinsView *viewIn);
|
||||||
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
||||||
bool HaveCoins(const uint256 &txid) const;
|
bool HaveCoins(const uint256 &txid) const;
|
||||||
uint256 GetBestBlock() const;
|
uint256 GetBestBlock() const;
|
||||||
|
@ -375,7 +375,7 @@ protected:
|
||||||
mutable CCoinsMap cacheCoins;
|
mutable CCoinsMap cacheCoins;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCoinsViewCache(CCoinsView &baseIn, bool fDummy = false);
|
CCoinsViewCache(CCoinsView *baseIn);
|
||||||
~CCoinsViewCache();
|
~CCoinsViewCache();
|
||||||
|
|
||||||
// Standard CCoinsView methods
|
// Standard CCoinsView methods
|
||||||
|
|
|
@ -958,7 +958,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
|
|
||||||
pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex);
|
pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex);
|
||||||
pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex);
|
pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex);
|
||||||
pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
|
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
|
||||||
|
|
||||||
if (fReindex)
|
if (fReindex)
|
||||||
pblocktree->WriteReindexing(true);
|
pblocktree->WriteReindexing(true);
|
||||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -896,12 +896,12 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
|
|
||||||
{
|
{
|
||||||
CCoinsView dummy;
|
CCoinsView dummy;
|
||||||
CCoinsViewCache view(dummy);
|
CCoinsViewCache view(&dummy);
|
||||||
|
|
||||||
int64_t nValueIn = 0;
|
int64_t nValueIn = 0;
|
||||||
{
|
{
|
||||||
LOCK(pool.cs);
|
LOCK(pool.cs);
|
||||||
CCoinsViewMemPool viewMemPool(*pcoinsTip, pool);
|
CCoinsViewMemPool viewMemPool(pcoinsTip, pool);
|
||||||
view.SetBackend(viewMemPool);
|
view.SetBackend(viewMemPool);
|
||||||
|
|
||||||
// do we already have it?
|
// do we already have it?
|
||||||
|
@ -1835,7 +1835,7 @@ bool static DisconnectTip(CValidationState &state) {
|
||||||
// Apply the block atomically to the chain state.
|
// Apply the block atomically to the chain state.
|
||||||
int64_t nStart = GetTimeMicros();
|
int64_t nStart = GetTimeMicros();
|
||||||
{
|
{
|
||||||
CCoinsViewCache view(*pcoinsTip, true);
|
CCoinsViewCache view(pcoinsTip);
|
||||||
if (!DisconnectBlock(block, state, pindexDelete, view))
|
if (!DisconnectBlock(block, state, pindexDelete, view))
|
||||||
return error("DisconnectTip() : DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString());
|
return error("DisconnectTip() : DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString());
|
||||||
assert(view.Flush());
|
assert(view.Flush());
|
||||||
|
@ -1888,7 +1888,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
||||||
int64_t nTime3;
|
int64_t nTime3;
|
||||||
LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001);
|
LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001);
|
||||||
{
|
{
|
||||||
CCoinsViewCache view(*pcoinsTip, true);
|
CCoinsViewCache view(pcoinsTip);
|
||||||
CInv inv(MSG_BLOCK, pindexNew->GetBlockHash());
|
CInv inv(MSG_BLOCK, pindexNew->GetBlockHash());
|
||||||
if (!ConnectBlock(*pblock, state, pindexNew, view)) {
|
if (!ConnectBlock(*pblock, state, pindexNew, view)) {
|
||||||
if (state.IsInvalid())
|
if (state.IsInvalid())
|
||||||
|
@ -2936,7 +2936,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
|
||||||
nCheckDepth = chainActive.Height();
|
nCheckDepth = chainActive.Height();
|
||||||
nCheckLevel = std::max(0, std::min(4, nCheckLevel));
|
nCheckLevel = std::max(0, std::min(4, nCheckLevel));
|
||||||
LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
|
LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
|
||||||
CCoinsViewCache coins(*coinsview, true);
|
CCoinsViewCache coins(coinsview);
|
||||||
CBlockIndex* pindexState = chainActive.Tip();
|
CBlockIndex* pindexState = chainActive.Tip();
|
||||||
CBlockIndex* pindexFailure = NULL;
|
CBlockIndex* pindexFailure = NULL;
|
||||||
int nGoodTransactions = 0;
|
int nGoodTransactions = 0;
|
||||||
|
|
|
@ -116,7 +116,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||||
{
|
{
|
||||||
LOCK2(cs_main, mempool.cs);
|
LOCK2(cs_main, mempool.cs);
|
||||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||||
CCoinsViewCache view(*pcoinsTip, true);
|
CCoinsViewCache view(pcoinsTip);
|
||||||
|
|
||||||
// Priority order to process transactions
|
// Priority order to process transactions
|
||||||
list<COrphan> vOrphan; // list memory doesn't move
|
list<COrphan> vOrphan; // list memory doesn't move
|
||||||
|
@ -316,7 +316,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||||
CBlockIndex indexDummy(*pblock);
|
CBlockIndex indexDummy(*pblock);
|
||||||
indexDummy.pprev = pindexPrev;
|
indexDummy.pprev = pindexPrev;
|
||||||
indexDummy.nHeight = pindexPrev->nHeight + 1;
|
indexDummy.nHeight = pindexPrev->nHeight + 1;
|
||||||
CCoinsViewCache viewNew(*pcoinsTip, true);
|
CCoinsViewCache viewNew(pcoinsTip);
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
if (!ConnectBlock(*pblock, state, &indexDummy, viewNew, true))
|
if (!ConnectBlock(*pblock, state, &indexDummy, viewNew, true))
|
||||||
throw std::runtime_error("CreateNewBlock() : ConnectBlock failed");
|
throw std::runtime_error("CreateNewBlock() : ConnectBlock failed");
|
||||||
|
|
|
@ -381,7 +381,7 @@ Value gettxout(const Array& params, bool fHelp)
|
||||||
CCoins coins;
|
CCoins coins;
|
||||||
if (fMempool) {
|
if (fMempool) {
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
CCoinsViewMemPool view(*pcoinsTip, mempool);
|
CCoinsViewMemPool view(pcoinsTip, mempool);
|
||||||
if (!view.GetCoins(hash, coins))
|
if (!view.GetCoins(hash, coins))
|
||||||
return Value::null;
|
return Value::null;
|
||||||
mempool.pruneSpent(hash, coins); // TODO: this should be done by the CCoinsViewMemPool
|
mempool.pruneSpent(hash, coins); // TODO: this should be done by the CCoinsViewMemPool
|
||||||
|
|
|
@ -557,11 +557,11 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
||||||
|
|
||||||
// Fetch previous transactions (inputs):
|
// Fetch previous transactions (inputs):
|
||||||
CCoinsView viewDummy;
|
CCoinsView viewDummy;
|
||||||
CCoinsViewCache view(viewDummy);
|
CCoinsViewCache view(&viewDummy);
|
||||||
{
|
{
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
CCoinsViewCache &viewChain = *pcoinsTip;
|
CCoinsViewCache &viewChain = *pcoinsTip;
|
||||||
CCoinsViewMemPool viewMempool(viewChain, mempool);
|
CCoinsViewMemPool viewMempool(&viewChain, mempool);
|
||||||
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
|
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) {
|
BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) {
|
||||||
|
|
|
@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
|
||||||
// The cache stack.
|
// The cache stack.
|
||||||
CCoinsViewTest base; // A CCoinsViewTest at the bottom.
|
CCoinsViewTest base; // A CCoinsViewTest at the bottom.
|
||||||
std::vector<CCoinsViewCache*> stack; // A stack of CCoinsViewCaches on top.
|
std::vector<CCoinsViewCache*> stack; // A stack of CCoinsViewCaches on top.
|
||||||
stack.push_back(new CCoinsViewCache(base, false)); // Start with one cache.
|
stack.push_back(new CCoinsViewCache(&base)); // Start with one cache.
|
||||||
|
|
||||||
// Use a limited set of random transaction ids, so we do test overwriting entries.
|
// Use a limited set of random transaction ids, so we do test overwriting entries.
|
||||||
std::vector<uint256> txids;
|
std::vector<uint256> txids;
|
||||||
|
@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
|
||||||
} else {
|
} else {
|
||||||
removed_all_caches = true;
|
removed_all_caches = true;
|
||||||
}
|
}
|
||||||
stack.push_back(new CCoinsViewCache(*tip, false));
|
stack.push_back(new CCoinsViewCache(tip));
|
||||||
if (stack.size() == 4) {
|
if (stack.size() == 4) {
|
||||||
reached_4_caches = true;
|
reached_4_caches = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CCoinsView coinsDummy;
|
CCoinsView coinsDummy;
|
||||||
CCoinsViewCache coins(coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
CBasicKeyStore keystore;
|
CBasicKeyStore keystore;
|
||||||
CKey key[6];
|
CKey key[6];
|
||||||
vector<CPubKey> keys;
|
vector<CPubKey> keys;
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct TestingSetup {
|
||||||
mapArgs["-datadir"] = pathTemp.string();
|
mapArgs["-datadir"] = pathTemp.string();
|
||||||
pblocktree = new CBlockTreeDB(1 << 20, true);
|
pblocktree = new CBlockTreeDB(1 << 20, true);
|
||||||
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
|
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
|
||||||
pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
|
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
|
||||||
InitBlockIndex();
|
InitBlockIndex();
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
bool fFirstRun;
|
bool fFirstRun;
|
||||||
|
|
|
@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(test_Get)
|
||||||
{
|
{
|
||||||
CBasicKeyStore keystore;
|
CBasicKeyStore keystore;
|
||||||
CCoinsView coinsDummy;
|
CCoinsView coinsDummy;
|
||||||
CCoinsViewCache coins(coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
|
||||||
CMutableTransaction t1;
|
CMutableTransaction t1;
|
||||||
|
@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CBasicKeyStore keystore;
|
CBasicKeyStore keystore;
|
||||||
CCoinsView coinsDummy;
|
CCoinsView coinsDummy;
|
||||||
CCoinsViewCache coins(coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
|
||||||
CMutableTransaction t;
|
CMutableTransaction t;
|
||||||
|
|
|
@ -630,7 +630,7 @@ void CTxMemPool::ClearPrioritisation(const uint256 hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView &baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
|
CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
|
||||||
|
|
||||||
bool CCoinsViewMemPool::GetCoins(const uint256 &txid, CCoins &coins) const {
|
bool CCoinsViewMemPool::GetCoins(const uint256 &txid, CCoins &coins) const {
|
||||||
// If an entry in the mempool exists, always return that one, as it's guaranteed to never
|
// If an entry in the mempool exists, always return that one, as it's guaranteed to never
|
||||||
|
|
|
@ -144,7 +144,7 @@ protected:
|
||||||
CTxMemPool &mempool;
|
CTxMemPool &mempool;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCoinsViewMemPool(CCoinsView &baseIn, CTxMemPool &mempoolIn);
|
CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn);
|
||||||
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
||||||
bool HaveCoins(const uint256 &txid) const;
|
bool HaveCoins(const uint256 &txid) const;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue