Introduce mc-util-lmdb crate containing a generic MetadataStore for lmdb database versioning #349
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.
Motivation
We implemented a simple versioning scheme for LedgerDB which allows us to prevent opening the database if it contains data that is incompatible with the code that is opening it. This behavior is desirable for other LMDB databases as well, such as mobilecoind's, watcher, etc.
In this PR
mc_ledger_db::MetadataStore
into a generic one that lives inside a newmc_util_lmdb
crate. Its a pretty trivial implementation, so maybe we want to just duplicate https://github.com/mobilecoinofficial/mobilecoin/blob/68a7b65c9fe515825d95278e47371ce0bb926194/ledger/db/src/metadata.rs into each place we use LMDB in - I am not sure. On one hand, the const-configuration-using-a-trait feels a bit forced, and on the other hand it does reduce code duplication significantly (I expect this code to be used in at least 5 places, I think?). Happy to hear thoughts on this.Future Work