[secretstore] create db_version file when database doesn't exist (#11570)
Fixes: https://github.com/openethereum/openethereum/issues/11569
This commit is contained in:
parent
9da1304539
commit
2bcc31928e
@ -134,6 +134,11 @@ mod server {
|
|||||||
|
|
||||||
const SECP_TEST_MESSAGE: H256 = H256([1_u8; 32]);
|
const SECP_TEST_MESSAGE: H256 = H256([1_u8; 32]);
|
||||||
|
|
||||||
|
/// Version of the secret store database
|
||||||
|
const SECRET_STORE_DB_VERSION: &str = "4";
|
||||||
|
/// Version file name
|
||||||
|
const SECRET_STORE_DB_VERSION_FILE_NAME: &str = "db_version";
|
||||||
|
|
||||||
fn into_service_contract_address(address: ContractAddress) -> parity_secretstore::ContractAddress {
|
fn into_service_contract_address(address: ContractAddress) -> parity_secretstore::ContractAddress {
|
||||||
match address {
|
match address {
|
||||||
ContractAddress::Registry => parity_secretstore::ContractAddress::Registry,
|
ContractAddress::Registry => parity_secretstore::ContractAddress::Registry,
|
||||||
@ -210,6 +215,13 @@ mod server {
|
|||||||
|
|
||||||
cconf.cluster_config.nodes.insert(self_secret.public().clone(), cconf.cluster_config.listener_address.clone());
|
cconf.cluster_config.nodes.insert(self_secret.public().clone(), cconf.cluster_config.listener_address.clone());
|
||||||
|
|
||||||
|
// Create a file containing the version of the database of the SecretStore
|
||||||
|
// when no database exists yet
|
||||||
|
if std::fs::read_dir(&conf.data_path).map_or(false, |mut list| list.next().is_none ()) {
|
||||||
|
std::fs::write(std::path::Path::new(&conf.data_path).join(SECRET_STORE_DB_VERSION_FILE_NAME), SECRET_STORE_DB_VERSION)
|
||||||
|
.map_err(|e| format!("Error creating SecretStore database version file: {}", e))?;
|
||||||
|
}
|
||||||
|
|
||||||
let db = parity_secretstore::open_secretstore_db(&conf.data_path)?;
|
let db = parity_secretstore::open_secretstore_db(&conf.data_path)?;
|
||||||
let trusted_client = TrustedClient::new(self_secret.clone(), deps.client, deps.sync, deps.miner);
|
let trusted_client = TrustedClient::new(self_secret.clone(), deps.client, deps.sync, deps.miner);
|
||||||
let key_server = parity_secretstore::start(trusted_client, self_secret, cconf, db, executor)
|
let key_server = parity_secretstore::start(trusted_client, self_secret, cconf, db, executor)
|
||||||
|
Loading…
Reference in New Issue
Block a user