coins: add Reset on CCoinsViewCache
Add a Reset() method to CCoinsViewCache that clears cacheCoins, cachedCoinsUsage, and hashBlock without flushing to the base view. Co-authored-by: l0rinc <pap.lorinc@gmail.com> Co-authored-by: sedited <seb.kung@gmail.com>
This commit is contained in:
2 files changed
+13
No files matched your search
@@ -274,6 +274,13 @@ void CCoinsViewCache::Sync()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCoinsViewCache::Reset() noexcept
|
||||||
|
{
|
||||||
|
cacheCoins.clear();
|
||||||
|
cachedCoinsUsage = 0;
|
||||||
|
hashBlock.SetNull();
|
||||||
|
}
|
||||||
|
|
||||||
void CCoinsViewCache::Uncache(const COutPoint& hash)
|
void CCoinsViewCache::Uncache(const COutPoint& hash)
|
||||||
{
|
{
|
||||||
CCoinsMap::iterator it = cacheCoins.find(hash);
|
CCoinsMap::iterator it = cacheCoins.find(hash);
|
||||||
|
|||||||
@@ -376,6 +376,12 @@ protected:
|
|||||||
/* Cached dynamic memory usage for the inner Coin objects. */
|
/* Cached dynamic memory usage for the inner Coin objects. */
|
||||||
mutable size_t cachedCoinsUsage{0};
|
mutable size_t cachedCoinsUsage{0};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discard all modifications made to this cache without flushing to the base view.
|
||||||
|
* This can be used to efficiently reuse a cache instance across multiple operations.
|
||||||
|
*/
|
||||||
|
void Reset() noexcept;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCoinsViewCache(CCoinsView *baseIn, bool deterministic = false);
|
CCoinsViewCache(CCoinsView *baseIn, bool deterministic = false);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user