aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2015-10-22 15:49:53 -0700
committerMatt Corallo <git@bluematt.me>2015-12-01 15:52:09 -0800
commit97bf377bd1f27ad841e1414e74361923a9f794f5 (patch)
tree636b92174fbced1d0bcc9238fdbbe00baf2b73c4 /src
parent677aa3d88c018a235d5b6d929e82f7b16e4f3e41 (diff)
downloadbitcoin-97bf377bd1f27ad841e1414e74361923a9f794f5.tar.xz
Add CCoinsViewCache::HaveCoinsInCache to check if a tx is cached
Diffstat (limited to 'src')
-rw-r--r--src/coins.cpp5
-rw-r--r--src/coins.h7
2 files changed, 12 insertions, 0 deletions
diff --git a/src/coins.cpp b/src/coins.cpp
index 060d6b7c5d..122bf4e48d 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();
diff --git a/src/coins.h b/src/coins.h
index 5beea711b2..60c1ba8a78 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -406,6 +406,13 @@ public:
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
/**
+ * Check if we have the given tx already loaded in this cache.
+ * The semantics are the same as HaveCoins(), but no calls to
+ * the backing CCoinsView are made.
+ */
+ bool HaveCoinsInCache(const uint256 &txid) const;
+
+ /**
* Return a pointer to CCoins in the cache, or NULL if not found. This is
* more efficient than GetCoins. Modifications to other cache entries are
* allowed while accessing the returned pointer.