[secretstore] migrate to version 4 (#11322)
* secret-store: migrate the db to version 4 * Fix secretstore build * Fix secretstore build: include ethkey when building with the "accounts" feature * fix build * secret-store: actually use new column * a bunch of fixes * last nits * Apply suggestions from code review Co-Authored-By: Niklas Adolfsson <niklasadolfsson1@gmail.com> * secret-store: move db stuff to secret-store as per Anton's request
This commit is contained in:
@@ -20,6 +20,3 @@
|
||||
mod impls;
|
||||
|
||||
pub use self::impls::{open_db_light, restoration_db_handler, migrate};
|
||||
|
||||
#[cfg(feature = "secretstore")]
|
||||
pub use self::impls::open_secretstore_db;
|
||||
|
||||
@@ -217,11 +217,11 @@ pub fn migrate(path: &Path, compaction_profile: &DatabaseCompactionProfile) -> R
|
||||
|
||||
// Further migrations
|
||||
if version < CURRENT_VERSION && exists(&db_path) {
|
||||
println!("Migrating database from version {} to {}", version, CURRENT_VERSION);
|
||||
info!(target: "migration", "Migrating database from version {} to {}", version, CURRENT_VERSION);
|
||||
migrate_database(version, &db_path, consolidated_database_migrations(&compaction_profile)?)?;
|
||||
|
||||
if version < BLOOMS_DB_VERSION {
|
||||
println!("Migrating blooms to blooms-db...");
|
||||
info!(target: "migration", "Migrating blooms to blooms-db...");
|
||||
let db_config = DatabaseConfig {
|
||||
max_open_files: 64,
|
||||
compaction: compaction_profile,
|
||||
@@ -232,7 +232,7 @@ pub fn migrate(path: &Path, compaction_profile: &DatabaseCompactionProfile) -> R
|
||||
migrate_blooms(&db_path, &db_config).map_err(Error::BloomsDB)?;
|
||||
}
|
||||
|
||||
println!("Migration finished");
|
||||
info!(target: "migration", "Migration finished");
|
||||
}
|
||||
|
||||
// update version file.
|
||||
|
||||
@@ -18,6 +18,9 @@ extern crate kvdb_rocksdb;
|
||||
extern crate migration_rocksdb;
|
||||
extern crate ethcore_blockchain;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate tempdir;
|
||||
|
||||
use std::{io, fs};
|
||||
use std::sync::Arc;
|
||||
use std::path::Path;
|
||||
@@ -56,17 +59,6 @@ impl BlockChainDB for AppDB {
|
||||
}
|
||||
}
|
||||
|
||||
/// Open a secret store DB using the given secret store data path. The DB path is one level beneath the data path.
|
||||
#[cfg(feature = "secretstore")]
|
||||
pub fn open_secretstore_db(data_path: &str) -> Result<Arc<dyn KeyValueDB>, String> {
|
||||
use std::path::PathBuf;
|
||||
|
||||
let mut db_path = PathBuf::from(data_path);
|
||||
db_path.push("db");
|
||||
let db_path = db_path.to_str().ok_or_else(|| "Invalid secretstore path".to_string())?;
|
||||
Ok(Arc::new(Database::open_default(&db_path).map_err(|e| format!("Error opening database: {:?}", e))?))
|
||||
}
|
||||
|
||||
/// Create a restoration db handler using the config generated by `client_path` and `client_config`.
|
||||
pub fn restoration_db_handler(client_path: &Path, client_config: &ClientConfig) -> Box<dyn BlockChainDBHandler> {
|
||||
let client_db_config = helpers::client_db_config(client_path, client_config);
|
||||
|
||||
Reference in New Issue
Block a user