Refactored block body database scheme (#10779)

* Refactored tx storage database scheme

* Bump parity-db

* fmt

* Fix handling invalid index size + test

* Removed superflous result

* Minor changes

* fmt
This commit is contained in:
Arkadiy Paronyan
2022-03-04 11:30:29 +01:00
committed by GitHub
parent e6b6c8aac6
commit 2bd493ff12
15 changed files with 332 additions and 295 deletions
+16 -2
View File
@@ -38,20 +38,22 @@ pub fn open<H: Clone + AsRef<[u8]>>(
path: &std::path::Path,
db_type: DatabaseType,
create: bool,
upgrade: bool,
) -> parity_db::Result<std::sync::Arc<dyn Database<H>>> {
let mut config = parity_db::Options::with_columns(path, NUM_COLUMNS as u8);
match db_type {
DatabaseType::Full => {
let indexes = [
let compressed = [
columns::STATE,
columns::HEADER,
columns::BODY,
columns::BODY_INDEX,
columns::TRANSACTION,
columns::JUSTIFICATIONS,
];
for i in indexes {
for i in compressed {
let mut column = &mut config.columns[i as usize];
column.compression = parity_db::CompressionType::Lz4;
}
@@ -60,9 +62,21 @@ pub fn open<H: Clone + AsRef<[u8]>>(
state_col.ref_counted = true;
state_col.preimage = true;
state_col.uniform = true;
let mut tx_col = &mut config.columns[columns::TRANSACTION as usize];
tx_col.ref_counted = true;
tx_col.preimage = true;
tx_col.uniform = true;
},
}
if upgrade {
log::info!("Upgrading database metadata.");
if let Some(meta) = parity_db::Options::load_metadata(path)? {
config.write_metadata(path, &meta.salt)?;
}
}
let db = if create {
parity_db::Db::open_or_create(&config)?
} else {