diff options
Diffstat (limited to 'src/coins.h')
-rw-r--r-- | src/coins.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/coins.h b/src/coins.h index 476db8f37c..4774c9f6a6 100644 --- a/src/coins.h +++ b/src/coins.h @@ -17,7 +17,6 @@ #include <assert.h> #include <stdint.h> -#include <boost/foreach.hpp> #include <unordered_map> /** @@ -207,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. @@ -222,8 +224,13 @@ public: /** * Return a reference to Coin in the cache, or a pruned one if not found. This is - * more efficient than GetCoin. Modifications to other cache entries are - * allowed while accessing the returned pointer. + * more efficient than GetCoin. + * + * Generally, do not hold the reference returned for more than a short scope. + * While the current implementation allows for modifications to the contents + * of the cache while holding the reference, this behavior should not be relied + * on! To be safe, best to not hold the returned reference through any other + * calls to this cache. */ const Coin& AccessCoin(const COutPoint &output) const; @@ -238,7 +245,7 @@ public: * If no unspent output exists for the passed outpoint, this call * has no effect. */ - void SpendCoin(const COutPoint &outpoint, Coin* moveto = nullptr); + bool SpendCoin(const COutPoint &outpoint, Coin* moveto = nullptr); /** * Push the modifications applied to this cache to its base. |