aboutsummaryrefslogtreecommitdiff
path: root/src/coins.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2015-12-02 10:12:19 +0100
committerWladimir J. van der Laan <[email protected]>2015-12-02 10:17:43 +0100
commitbdda4d567eedd44d3088980fa47ab03827103f68 (patch)
tree085c3f0ff182276ba87cc9eb1c2b8713ba503231 /src/coins.cpp
parentMerge pull request #7040 (diff)
parentFlush coins cache also after transaction processing (diff)
downloaddiscoin-bdda4d567eedd44d3088980fa47ab03827103f68.tar.xz
discoin-bdda4d567eedd44d3088980fa47ab03827103f68.zip
Merge pull request #6872
dd5862c Flush coins cache also after transaction processing (Pieter Wuille) bde953e Uncache input txn in utxo cache if a tx is not accepted to mempool (Matt Corallo) 97bf377 Add CCoinsViewCache::HaveCoinsInCache to check if a tx is cached (Matt Corallo) 677aa3d Discard txn cache entries that were loaded for removed mempool txn (Matt Corallo) b2e74bd Get the set of now-uncacheable-txn from CTxMemPool::TrimToSize (Matt Corallo) 74d0f90 Add method to remove a tx from CCoinsViewCache if it is unchanged (Matt Corallo)
Diffstat (limited to 'src/coins.cpp')
-rw-r--r--src/coins.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/coins.cpp b/src/coins.cpp
index 723e11470..122bf4e48 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -144,6 +144,11 @@ bool CCoinsViewCache::HaveCoins(const uint256 &txid) const {
return (it != cacheCoins.end() && !it->second.coins.vout.empty());
}
+bool CCoinsViewCache::HaveCoinsInCache(const uint256 &txid) const {
+ CCoinsMap::const_iterator it = cacheCoins.find(txid);
+ return it != cacheCoins.end();
+}
+
uint256 CCoinsViewCache::GetBestBlock() const {
if (hashBlock.IsNull())
hashBlock = base->GetBestBlock();
@@ -206,6 +211,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();
}