Add mechanism to load v0.22.3 snapshots on newer Solana versions

This commit is contained in:
Michael Vines
2020-01-21 22:06:21 -07:00
parent 9bd6be779f
commit 934c32cbc6
3 changed files with 160 additions and 5 deletions

View File

@ -1,6 +1,6 @@
use solana_ledger::snapshot_package::{SnapshotPackage, SnapshotPackageReceiver};
use solana_ledger::snapshot_utils::{
serialize_status_cache, SnapshotError, TAR_ACCOUNTS_DIR, TAR_SNAPSHOTS_DIR,
serialize_status_cache, SnapshotError, TAR_ACCOUNTS_DIR, TAR_SNAPSHOTS_DIR, TAR_VERSION_FILE,
};
use solana_measure::measure::Measure;
use solana_metrics::datapoint_info;
@ -91,6 +91,7 @@ impl SnapshotPackagerService {
let staging_dir = TempDir::new()?;
let staging_accounts_dir = staging_dir.path().join(TAR_ACCOUNTS_DIR);
let staging_snapshots_dir = staging_dir.path().join(TAR_SNAPSHOTS_DIR);
let staging_version_file = staging_dir.path().join(TAR_VERSION_FILE);
fs::create_dir_all(&staging_accounts_dir)?;
// Add the snapshots to the staging directory
@ -119,6 +120,15 @@ impl SnapshotPackagerService {
}
}
// Write version file
{
use std::io::Write;
let snapshot_version = format!("{}\n", env!("CARGO_PKG_VERSION"));
let mut f = std::fs::File::create(staging_version_file)?;
//f.write_all(&snapshot_version.to_string().into_bytes())?;
f.write_all(&snapshot_version.into_bytes())?;
}
// Tar the staging directory into the archive at `archive_path`
let archive_path = tar_dir.join("new_state.tar.bz2");
let args = vec![
@ -128,6 +138,7 @@ impl SnapshotPackagerService {
staging_dir.path().to_str().unwrap(),
TAR_ACCOUNTS_DIR,
TAR_SNAPSHOTS_DIR,
TAR_VERSION_FILE,
];
let output = std::process::Command::new("tar").args(&args).output()?;