Accounts bloom (#2357)
* proper bloom * incremental bloom updates * crate update * return of the column * fix n^2 byteorder write * add notes to funs * working bloom commits * Optimizations * bloom diag * migration basic * migration ongoing * migration finalizing * mingration api workarounds * fix test_client setups * snapshot bloom update * review fixes * just forward keys in the migration * migration extra tracing * fix migration path * remove close pray * review issues
This commit is contained in:
committed by
Arkadiy Paronyan
parent
2d623f14db
commit
4d115987cb
@@ -29,7 +29,7 @@ use ethcore::migrations::Extract;
|
||||
/// Database is assumed to be at default version, when no version file is found.
|
||||
const DEFAULT_VERSION: u32 = 5;
|
||||
/// Current version of database models.
|
||||
const CURRENT_VERSION: u32 = 9;
|
||||
const CURRENT_VERSION: u32 = 10;
|
||||
/// First version of the consolidated database.
|
||||
const CONSOLIDATION_VERSION: u32 = 9;
|
||||
/// Defines how many items are migrated to the new version of database at once.
|
||||
@@ -140,7 +140,12 @@ pub fn default_migration_settings(compaction_profile: &CompactionProfile) -> Mig
|
||||
|
||||
/// Migrations on the consolidated database.
|
||||
fn consolidated_database_migrations(compaction_profile: &CompactionProfile) -> Result<MigrationManager, Error> {
|
||||
let manager = MigrationManager::new(default_migration_settings(compaction_profile));
|
||||
let mut manager = MigrationManager::new(default_migration_settings(compaction_profile));
|
||||
// this won't ever fire, because version will be already 9
|
||||
// added because migration api should know that it should open database with 5 columns
|
||||
try!(manager.add_migration(migrations::ToV9::new(Some(5), migrations::Extract::All)).map_err(|_| Error::MigrationImpossible));
|
||||
// this will
|
||||
try!(manager.add_migration(migrations::ToV10).map_err(|_| Error::MigrationImpossible));
|
||||
Ok(manager)
|
||||
}
|
||||
|
||||
@@ -180,7 +185,6 @@ fn consolidate_database(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// Migrates database at given position with given migration rules.
|
||||
fn migrate_database(version: u32, db_path: PathBuf, mut migrations: MigrationManager) -> Result<(), Error> {
|
||||
// check if migration is needed
|
||||
@@ -215,6 +219,12 @@ fn exists(path: &Path) -> bool {
|
||||
fs::metadata(path).is_ok()
|
||||
}
|
||||
|
||||
// in-place upgrades that do nothing when called repeatedly
|
||||
fn run_inplace_upgrades(path: &Path) -> Result<(), Error> {
|
||||
try!(migrations::upgrade_account_bloom(path));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Migrates the database.
|
||||
pub fn migrate(path: &Path, pruning: Algorithm, compaction_profile: CompactionProfile) -> Result<(), Error> {
|
||||
// read version file.
|
||||
@@ -228,6 +238,7 @@ pub fn migrate(path: &Path, pruning: Algorithm, compaction_profile: CompactionPr
|
||||
|
||||
// We are in the latest version, yay!
|
||||
if version == CURRENT_VERSION {
|
||||
try!(run_inplace_upgrades(consolidated_database_path(path).as_path()));
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
@@ -259,6 +270,8 @@ pub fn migrate(path: &Path, pruning: Algorithm, compaction_profile: CompactionPr
|
||||
println!("Migration finished");
|
||||
}
|
||||
|
||||
try!(run_inplace_upgrades(consolidated_database_path(path).as_path()));
|
||||
|
||||
// update version file.
|
||||
update_version(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user