Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine handling of txdb and namedb #86

Merged
merged 7 commits into from
Jun 2, 2014

Conversation

domob1812
Copy link
Contributor

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.)

Optionally allow specifying an existing DbTxn to use in TxnBegin of the
DBs, so that one can use an atomic transaction across multiple databases
to fix syncing issues in the future.
Implement better support for reusing database transactions to
synchronise multiple DBs with TxnBegin(parent-txn).  Keep track of which
transactions are our own, and only abort/commit those.
In the changes introduced to TxnCommit/TxnAbort due to ownTxn, the
return value was ignored so far due to an oversight.  Correct this.
Optionally allow specifying an existing DbTxn to use in TxnBegin of the
DBs, so that one can use an atomic transaction across multiple databases
to fix syncing issues in the future.
Move the CNameDB class to db.h and move the definition of vchType to
headers.  Fix the includes in other files so that everything compiles.
Introduce a new class DatabaseSet that wraps around the "blockchain
status databases" CTxDB and CNameDB.  Use it instead of the classes
themselves for blockchain validation.  The only net effect this has is
that CNameDB is not created/destroyed in each Connect/DisconnectInputs
hook, but at the same time as the CTxDB.  It possibly also fixes syncing
between both with atomic transactions.
Ensure that the nameindex database is created before loading the block
index when it does not yet exist, otherwise using DatabaseSet fails.
@phelixbtc
Copy link
Contributor

ACK

phelixbtc added a commit that referenced this pull request Jun 2, 2014
Combine handling of txdb and namedb
@phelixbtc phelixbtc merged commit 6f3e10f into namecoin:namecoinq Jun 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants