Combine handling of txdb and namedb #86
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch creates a wrapper class around CTxDB and CNameDB, which are the databases needed for transaction processing. This cleans things up a bit and makes it easier in the future to add more databases, for instance to keep track of the UTXO set.
The only "material" change it makes is that previously, the required CNameDB object was constructed & closed when processing each name transaction in a block. The CTxDB object is constructed only once and a single transaction performed with it, on the other hand. With the patch, both databases are opened and closed only once for processing a series of transactions.
This is the way it should be, IMO. It probably helps with performance (I've no measured data, though) and it helps prevent data inconsistencies between both databases since every update is done to both in a single, atomic BDB transaction. (Snailbrain mentioned to me once that Mikhail thought about this issue, too.)