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

Introduce mc-util-lmdb crate containing a generic MetadataStore for lmdb database versioning #349

Merged

Conversation

eranrund
Copy link
Contributor

@eranrund eranrund commented Aug 5, 2020

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

Future Work

  • If we move on with this, add it to other LMDB users in this repo (mobilecoind, watcher).

/// Metadata store settings that are used for version control.
#[derive(Clone, Default, Debug)]
pub struct LedgerDbMetadataStoreSettings;
impl MetadataStoreSettings for LedgerDbMetadataStoreSettings {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff is the main idea behind the work proposed in this PR. Each LMDB user would need to have this, instead of duplicating the entire metadata_store.rs file.

/// release.
pub created_by_crate_version: String,

_s: S,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this would've been PhantomData<S> instead, but Rust doesn't like that (rust-lang/rust#46969 might be related).

Copy link
Contributor

@sugargoat sugargoat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a reasonable direction to me, and +1 for code duplication reduction.

@eranrund eranrund merged commit 22a01c9 into mobilecoinfoundation:master Aug 5, 2020
@eranrund eranrund deleted the reusable-lmdb-metadata branch August 5, 2020 23:05
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.

3 participants