diff options
author | Alex Morcos <morcos@chaincode.com> | 2015-11-12 16:57:03 -0500 |
---|---|---|
committer | Alex Morcos <morcos@chaincode.com> | 2015-11-18 12:16:40 -0500 |
commit | 8504867b146014c99c6acb180020a1369069c761 (patch) | |
tree | eb651ea7ab069c76e1252d8617c260250f5edc5d /src/main.cpp | |
parent | 072e2f864445bc6ef3b390255f08c9e8bec2ea94 (diff) |
Save the last unnecessary database read
It's possible coins with the same hash exist when you create a duplicate coinbase, so previously we were reading from the database to make sure we had the old coins cached so if we were to spend the new ones, the old ones would also be spent. This pull instead just marks the new coins as not fresh if they are from a coinbase, so if they are spent they will be written all the way down to the database anyway overwriting any duplicates.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp index 8fb121c00d..3c9c77ef67 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1310,17 +1310,9 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach undo.nVersion = coins->nVersion; } } - // add outputs - inputs.ModifyNewCoins(tx.GetHash())->FromTx(tx, nHeight); - } - else { - // add outputs for coinbase tx - // In this case call the full ModifyCoins which will do a database - // lookup to be sure the coins do not already exist otherwise we do not - // know whether to mark them fresh or not. We want the duplicate coinbases - // before BIP30 to still be properly overwritten. - inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight); } + // add outputs + inputs.ModifyNewCoins(tx.GetHash(), tx.IsCoinBase())->FromTx(tx, nHeight); } void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight) |