diff --git a/kvdb-rocksdb/CHANGELOG.md b/kvdb-rocksdb/CHANGELOG.md index 148f0815d..a1594f876 100644 --- a/kvdb-rocksdb/CHANGELOG.md +++ b/kvdb-rocksdb/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog]. ## [Unreleased] +## [0.13.0] - 2021-08-04 +### Breaking +- `DatabaseConfig` is now `#[non_exhaustive]`. [#576](https://github.com/paritytech/parity-common/pull/576) +- Added `create_if_missing` to `DatabaseConfig`. [#576](https://github.com/paritytech/parity-common/pull/576) + ## [0.12.1] - 2021-07-30 - Bumped `rocksdb` to 0.17. [#573](https://github.com/paritytech/parity-common/pull/573) diff --git a/kvdb-rocksdb/Cargo.toml b/kvdb-rocksdb/Cargo.toml index 400ae7f52..c4c7588ca 100644 --- a/kvdb-rocksdb/Cargo.toml +++ b/kvdb-rocksdb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kvdb-rocksdb" -version = "0.12.1" +version = "0.13.0" authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" description = "kvdb implementation backed by RocksDB" diff --git a/kvdb-rocksdb/src/lib.rs b/kvdb-rocksdb/src/lib.rs index 03a4eafe5..9089d4cf0 100644 --- a/kvdb-rocksdb/src/lib.rs +++ b/kvdb-rocksdb/src/lib.rs @@ -142,6 +142,7 @@ impl CompactionProfile { /// Database configuration #[derive(Clone)] +#[non_exhaustive] pub struct DatabaseConfig { /// Max number of open files. pub max_open_files: i32, @@ -180,6 +181,9 @@ pub struct DatabaseConfig { /// Limit the size (in bytes) of write ahead logs /// More info: https://github.com/facebook/rocksdb/wiki/Write-Ahead-Log pub max_total_wal_size: Option, + /// Creates a new database if no database exists. + /// Set to `true` by default for backwards compatibility. + pub create_if_missing: bool, } impl DatabaseConfig { @@ -233,6 +237,7 @@ impl Default for DatabaseConfig { enable_statistics: false, secondary: None, max_total_wal_size: None, + create_if_missing: true, } } } @@ -325,7 +330,7 @@ fn generate_options(config: &DatabaseConfig) -> Options { opts.enable_statistics(); } opts.set_use_fsync(false); - opts.create_if_missing(true); + opts.create_if_missing(config.create_if_missing); if config.secondary.is_some() { opts.set_max_open_files(-1) } else { @@ -376,7 +381,7 @@ fn generate_block_based_options(config: &DatabaseConfig) -> io::Result