Merge pull request #1594 from rphmeier/migration_progress

V7 Migration progress indicator
This commit is contained in:
Tomasz Drwięga
2016-07-12 17:23:03 +02:00
committed by GitHub
2 changed files with 17 additions and 3 deletions

View File

@@ -61,8 +61,9 @@ fn attempt_migrate(mut key_h: H256, val: &[u8]) -> Option<H256> {
}
}
/// Version for `ArchiveDB`.
pub struct ArchiveV7;
/// Version for ArchiveDB.
#[derive(Default)]
pub struct ArchiveV7(usize);
impl SimpleMigration for ArchiveV7 {
fn version(&self) -> u32 {
@@ -70,6 +71,12 @@ impl SimpleMigration for ArchiveV7 {
}
fn simple_migrate(&mut self, key: Vec<u8>, value: Vec<u8>) -> Option<(Vec<u8>, Vec<u8>)> {
self.0 += 1;
if self.0 == 100_000 {
self.0 = 0;
flush!(".");
}
if key.len() != 32 {
// metadata key, ignore.
return Some((key, value));
@@ -228,7 +235,14 @@ impl Migration for OverlayRecentV7 {
_ => return Err(Error::MigrationImpossible), // missing or wrong version
}
let mut count = 0;
for (key, value) in source.iter() {
count += 1;
if count == 100_000 {
count = 0;
flush!(".");
}
let mut key = key.into_vec();
if key.len() == 32 {
let key_h = H256::from_slice(&key[..]);