lighthouse-pulse/lighthouse/db/mod.rs
2018-08-16 14:17:28 +10:00

15 lines
378 B
Rust

extern crate rocksdb;
use std::fs;
use std::path::Path;
pub use self::rocksdb::DB;
pub fn open_db(path: &Path) -> DB {
let db_path = path.join("rocksdb");
fs::create_dir_all(&db_path)
.expect(&format!("Unable to create {:?}", &db_path));
let db = DB::open_default(db_path.join("lighthouse.rdb"))
.expect("Unable to open local database.");
db
}