aboutsummaryrefslogtreecommitdiff
path: root/src/coins.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-01-22 14:15:45 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2016-01-22 14:15:52 +0100
commit6a0720838873c7e13a936a74349147b954e50255 (patch)
tree5e71531ba72eff2133b29baa1415aa84278f8aba /src/coins.cpp
parent93b05764d5e4c6a4a5f11bfe70942baf9eaa0076 (diff)
parent8504867b146014c99c6acb180020a1369069c761 (diff)
Merge #7056: Save last db read
8504867 Save the last unnecessary database read (Alex Morcos)
Diffstat (limited to 'src/coins.cpp')
-rw-r--r--src/coins.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/coins.cpp b/src/coins.cpp
index 4d1dbdea4e..877fb8b26c 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -117,11 +117,17 @@ CCoinsModifier CCoinsViewCache::ModifyCoins(const uint256 &txid) {
return CCoinsModifier(*this, ret.first, cachedCoinUsage);
}
-CCoinsModifier CCoinsViewCache::ModifyNewCoins(const uint256 &txid) {
+// ModifyNewCoins has to know whether the new outputs its creating are for a
+// coinbase or not. If they are for a coinbase, it can not mark them as fresh.
+// This is to ensure that the historical duplicate coinbases before BIP30 was
+// in effect will still be properly overwritten when spent.
+CCoinsModifier CCoinsViewCache::ModifyNewCoins(const uint256 &txid, bool coinbase) {
assert(!hasModifier);
std::pair<CCoinsMap::iterator, bool> ret = cacheCoins.insert(std::make_pair(txid, CCoinsCacheEntry()));
ret.first->second.coins.Clear();
- ret.first->second.flags = CCoinsCacheEntry::FRESH;
+ if (!coinbase) {
+ ret.first->second.flags = CCoinsCacheEntry::FRESH;
+ }
ret.first->second.flags |= CCoinsCacheEntry::DIRTY;
return CCoinsModifier(*this, ret.first, 0);
}