Changeset View
Changeset View
Standalone View
Standalone View
src/coins.h
Show First 20 Lines • Show All 434 Lines • ▼ Show 20 Lines | public: | ||||
CCoinsViewCursor *Cursor() const; | CCoinsViewCursor *Cursor() const; | ||||
}; | }; | ||||
/** | /** | ||||
* CCoinsView that adds a memory cache for transactions to another CCoinsView | * CCoinsView that adds a memory cache for transactions to another CCoinsView | ||||
*/ | */ | ||||
class CCoinsViewCache : public CCoinsViewBacked { | class CCoinsViewCache : public CCoinsViewBacked { | ||||
protected: | protected: | ||||
/* Whether this cache has an active modifier. */ | |||||
bool hasModifier; | |||||
/** | /** | ||||
* Make mutable so that we can "fill the cache" even from Get-methods | * Make mutable so that we can "fill the cache" even from Get-methods | ||||
* declared as "const". | * declared as "const". | ||||
*/ | */ | ||||
mutable uint256 hashBlock; | mutable uint256 hashBlock; | ||||
mutable CCoinsMap cacheCoins; | mutable CCoinsMap cacheCoins; | ||||
/* Cached dynamic memory usage for the inner CCoins objects. */ | /* Cached dynamic memory usage for the inner CCoins objects. */ | ||||
mutable size_t cachedCoinsUsage; | mutable size_t cachedCoinsUsage; | ||||
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; | ||||
/** | /** | ||||
* Return a pointer to CCoins in the cache, or nullptr if not found. This is | * Return a pointer to CCoins in the cache, or nullptr if not found. This is | ||||
* more efficient than GetCoins. Modifications to other cache entries are | * more efficient than GetCoins. Modifications to other cache entries are | ||||
* allowed while accessing the returned pointer. | * allowed while accessing the returned pointer. | ||||
*/ | */ | ||||
const CCoins *AccessCoins(const uint256 &txid) const; | const CCoins *AccessCoins(const uint256 &txid) const; | ||||
public: | public: | ||||
CCoinsViewCache(CCoinsView *baseIn); | CCoinsViewCache(CCoinsView *baseIn); | ||||
~CCoinsViewCache(); | |||||
// Standard CCoinsView methods | // Standard CCoinsView methods | ||||
uint256 GetBestBlock() const; | uint256 GetBestBlock() const; | ||||
void SetBestBlock(const uint256 &hashBlock); | void SetBestBlock(const uint256 &hashBlock); | ||||
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock); | bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock); | ||||
/** | /** | ||||
* Check if we have the given utxo already loaded in this cache. | * Check if we have the given utxo already loaded in this cache. | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |