diff options
author | Alex Morcos <morcos@chaincode.com> | 2015-11-02 21:27:15 -0500 |
---|---|---|
committer | Alex Morcos <morcos@chaincode.com> | 2015-11-02 21:27:15 -0500 |
commit | 14470f9aa6baf02ca7162564f397153a2da0c592 (patch) | |
tree | 7fb16312c72044614b80f243347ee1cb1ac0b390 /src/coins.h | |
parent | 8fe30fb4d130532d4a0e4c9d143f03e1b85a749e (diff) |
ModifyNewCoins saves database lookups
When processing a new transaction, in addition to spending the Coins of its txin's it creates a new Coins for its outputs. The existing ModifyCoins function will first make sure this Coins does not already exist. It can not exist due to BIP 30, but because of that the lookup can't be cached and always has to go to the database. Since we are creating the coins to match the new tx anyway, there is no point in checking if they exist first anyway. However this should not be used for coinbase tx's in order to preserve the historical behavior of overwriting the two existing duplicate tx pairs.
Diffstat (limited to 'src/coins.h')
-rw-r--r-- | src/coins.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/coins.h b/src/coins.h index bf4a777b8a..3b45cb0a34 100644 --- a/src/coins.h +++ b/src/coins.h @@ -420,6 +420,17 @@ public: CCoinsModifier ModifyCoins(const uint256 &txid); /** + * Return a modifiable reference to a CCoins. Assumes that no entry with the given + * txid exists and creates a new one. This saves a database access in the case where + * the coins were to be wiped out by FromTx anyway. This should not be called with + * the 2 historical coinbase duplicate pairs because the new coins are marked fresh, and + * in the event the duplicate coinbase was spent before a flush, the now pruned coins + * would not properly overwrite the first coinbase of the pair. Simultaneous modifications + * are not allowed. + */ + CCoinsModifier ModifyNewCoins(const uint256 &txid); + + /** * Push the modifications applied to this cache to its base. * Failure to call this method before destruction will cause the changes to be forgotten. * If false is returned, the state of this cache (and its backing view) will be undefined. |