Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 2bcc319

Browse files
authored
[secretstore] create db_version file when database doesn't exist (#11570)
Fixes: https://github.com/openethereum/openethereum/issues/11569
1 parent 9da1304 commit 2bcc319

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

parity/secretstore/server.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ mod server {
134134

135135
const SECP_TEST_MESSAGE: H256 = H256([1_u8; 32]);
136136

137+
/// Version of the secret store database
138+
const SECRET_STORE_DB_VERSION: &str = "4";
139+
/// Version file name
140+
const SECRET_STORE_DB_VERSION_FILE_NAME: &str = "db_version";
141+
137142
fn into_service_contract_address(address: ContractAddress) -> parity_secretstore::ContractAddress {
138143
match address {
139144
ContractAddress::Registry => parity_secretstore::ContractAddress::Registry,
@@ -210,6 +215,13 @@ mod server {
210215

211216
cconf.cluster_config.nodes.insert(self_secret.public().clone(), cconf.cluster_config.listener_address.clone());
212217

218+
// Create a file containing the version of the database of the SecretStore
219+
// when no database exists yet
220+
if std::fs::read_dir(&conf.data_path).map_or(false, |mut list| list.next().is_none ()) {
221+
std::fs::write(std::path::Path::new(&conf.data_path).join(SECRET_STORE_DB_VERSION_FILE_NAME), SECRET_STORE_DB_VERSION)
222+
.map_err(|e| format!("Error creating SecretStore database version file: {}", e))?;
223+
}
224+
213225
let db = parity_secretstore::open_secretstore_db(&conf.data_path)?;
214226
let trusted_client = TrustedClient::new(self_secret.clone(), deps.client, deps.sync, deps.miner);
215227
let key_server = parity_secretstore::start(trusted_client, self_secret, cconf, db, executor)

0 commit comments

Comments
 (0)