v7 migration progress
This commit is contained in:
		
							parent
							
								
									bdf4446173
								
							
						
					
					
						commit
						7e13ce6185
					
				| @ -62,7 +62,8 @@ fn attempt_migrate(mut key_h: H256, val: &[u8]) -> Option<H256> { | ||||
| } | ||||
| 
 | ||||
| /// Version for ArchiveDB.
 | ||||
| pub struct ArchiveV7; | ||||
| #[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; | ||||
| 			println!("."); | ||||
| 		} | ||||
| 
 | ||||
| 		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; | ||||
| 				println!("."); | ||||
| 			} | ||||
| 
 | ||||
| 			let mut key = key.into_vec(); | ||||
| 			if key.len() == 32 { | ||||
| 				let key_h = H256::from_slice(&key[..]); | ||||
|  | ||||
| @ -157,7 +157,7 @@ fn extras_database_migrations() -> Result<MigrationManager, Error> { | ||||
| fn state_database_migrations(pruning: Algorithm) -> Result<MigrationManager, Error> { | ||||
| 	let mut manager = MigrationManager::new(default_migration_settings()); | ||||
| 	let res = match pruning { | ||||
| 		Algorithm::Archive => manager.add_migration(migrations::state::ArchiveV7), | ||||
| 		Algorithm::Archive => manager.add_migration(migrations::state::ArchiveV7::default()), | ||||
| 		Algorithm::OverlayRecent => manager.add_migration(migrations::state::OverlayRecentV7::default()), | ||||
| 		_ => die!("Unsupported pruning method for migration. Delete DB and resync"), | ||||
| 	}; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user