Store the database in a role specific subdirectory (#9645)

* Store the database in a role specific subdirectory

This is a cleaned up version of #8658 fixing #6880

polkadot companion: paritytech/polkadot#2923

* Disable prometheus in tests

* Also change p2p port

* Fix migration logic

* Use different identification file for rocks and parity db

Add tests for paritydb migration
This commit is contained in:
Falco Hirschenberger
2021-09-07 15:31:25 +02:00
committed by GitHub
parent 4849e34270
commit 16144e7404
12 changed files with 317 additions and 24 deletions
+17 -1
View File
@@ -355,7 +355,7 @@ pub enum DatabaseSource {
}
impl DatabaseSource {
/// Return dabase path for databases that are on the disk.
/// Return path for databases that are stored on disk.
pub fn path(&self) -> Option<&Path> {
match self {
// as per https://github.com/paritytech/substrate/pull/9500#discussion_r684312550
@@ -367,6 +367,22 @@ impl DatabaseSource {
DatabaseSource::Custom(..) => None,
}
}
/// Set path for databases that are stored on disk.
pub fn set_path(&mut self, p: &Path) -> bool {
match self {
DatabaseSource::Auto { ref mut paritydb_path, .. } => {
*paritydb_path = p.into();
true
},
DatabaseSource::RocksDb { ref mut path, .. } |
DatabaseSource::ParityDb { ref mut path } => {
*path = p.into();
true
},
DatabaseSource::Custom(..) => false,
}
}
}
impl std::fmt::Display for DatabaseSource {