Browse Source

Add method to remove a tx from CCoinsViewCache if it is unchanged

0.13
Matt Corallo 9 years ago
parent
commit
74d0f90262
  1. 9
      src/coins.cpp
  2. 6
      src/coins.h

9
src/coins.cpp

@ -206,6 +206,15 @@ bool CCoinsViewCache::Flush() { @@ -206,6 +206,15 @@ bool CCoinsViewCache::Flush() {
return fOk;
}
void CCoinsViewCache::Uncache(const uint256& hash)
{
CCoinsMap::iterator it = cacheCoins.find(hash);
if (it != cacheCoins.end() && it->second.flags == 0) {
cachedCoinsUsage -= it->second.coins.DynamicMemoryUsage();
cacheCoins.erase(it);
}
}
unsigned int CCoinsViewCache::GetCacheSize() const {
return cacheCoins.size();
}

6
src/coins.h

@ -437,6 +437,12 @@ public: @@ -437,6 +437,12 @@ public:
*/
bool Flush();
/**
* Removes the transaction with the given hash from the cache, if it is
* not modified.
*/
void Uncache(const uint256 &txid);
//! Calculate the size of the cache (in number of transactions)
unsigned int GetCacheSize() const;

Loading…
Cancel
Save