From 228d2385254ee136ef64d229a414fdd7cefea9a0 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 31 Dec 2014 03:19:24 +0000 Subject: [PATCH 1/2] Make CCoinsViewCache's copy constructor private It is easily confused with CCoinsViewCache(CCoinsView*), which creates a sub-cache, but instead of creating a sub-cache, the copy constructor would copy the original and use that original's base, defeating the intended isolation. --- src/coins.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coins.h b/src/coins.h index dbe3f8bd31..e6ba168949 100644 --- a/src/coins.h +++ b/src/coins.h @@ -441,6 +441,11 @@ public: private: CCoinsMap::iterator FetchCoins(const uint256 &txid); CCoinsMap::const_iterator FetchCoins(const uint256 &txid) const; + + /** + * By making the copy constructor private, we prevent accidentally using it when one intends to create a cache on top of a base cache. + */ + CCoinsViewCache(const CCoinsViewCache &); }; #endif // BITCOIN_COINS_H From 1b178a7f966cd3649b7f0a52ffc4b8ef4c227900 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 31 Dec 2014 03:28:05 +0000 Subject: [PATCH 2/2] Bugfix: ConnectBlock: In case the genesis block gets in with fJustCheck, behave correctly --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 70e3973e6c..7c5b7401ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1616,7 +1616,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Special case for the genesis block, skipping connection of its transactions // (its coinbase is unspendable) if (block.GetHash() == Params().HashGenesisBlock()) { - view.SetBestBlock(pindex->GetBlockHash()); + if (!fJustCheck) + view.SetBestBlock(pindex->GetBlockHash()); return true; }