[1.1.0] LMDB Naming consistency fix (#2656)

* allow separate db name in store creation

* rustfmt

* fixes to db paths to ensure consistency with 1.0.x
This commit is contained in:
Yeastplume
2019-03-06 17:34:39 +00:00
committed by GitHub
parent 6fa137a4ff
commit fd077a489d
5 changed files with 19 additions and 9 deletions
+13 -4
View File
@@ -75,12 +75,21 @@ impl Store {
/// By default creates an environment named "lmdb".
/// Be aware of transactional semantics in lmdb
/// (transactions are per environment, not per database).
pub fn new(path: &str, name: Option<&str>, max_readers: Option<u32>) -> Result<Store, Error> {
let name = match name {
pub fn new(
root_path: &str,
env_name: Option<&str>,
db_name: Option<&str>,
max_readers: Option<u32>,
) -> Result<Store, Error> {
let name = match env_name {
Some(n) => n.to_owned(),
None => "lmdb".to_owned(),
};
let full_path = [path.to_owned(), name.clone()].join("/");
let db_name = match db_name {
Some(n) => n.to_owned(),
None => "lmdb".to_owned(),
};
let full_path = [root_path.to_owned(), name.clone()].join("/");
fs::create_dir_all(&full_path)
.expect("Unable to create directory 'db_root' to store chain_data");
@@ -101,7 +110,7 @@ impl Store {
let res = Store {
env: Arc::new(env),
db: RwLock::new(None),
name: name,
name: db_name,
};
{