Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
svenski123 committed May 11, 2020
1 parent 0cb9094 commit c52f79e
Show file tree
Hide file tree
Showing 14 changed files with 430 additions and 527 deletions.
4 changes: 2 additions & 2 deletions core/src/accounts_hash_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ mod tests {
use crate::cluster_info::make_accounts_hashes_message;
use crate::contact_info::ContactInfo;
use solana_ledger::bank_forks::CompressionType;
use solana_ledger::snapshot_utils::SnapshotVersion;
use solana_sdk::{
hash::hash,
signature::{Keypair, Signer},
};
use solana_ledger::snapshot_utils::SnapshotVersion;

#[test]
fn test_should_halt() {
Expand Down Expand Up @@ -240,7 +240,7 @@ mod tests {
tar_output_file: PathBuf::from("."),
storages: vec![],
compression: CompressionType::Bzip2,
snapshot_version: SnapshotVersion::default(),
snapshot_version: SnapshotVersion::default(),
};

AccountsHashVerifier::process_accounts_package(
Expand Down
4 changes: 2 additions & 2 deletions core/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ mod tests {
bank_forks::CompressionType,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path,
snapshot_utils::SnapshotVersion,
snapshot_utils::SnapshotVersion,
};
use solana_runtime::bank::Bank;
use solana_sdk::signature::Signer;
Expand Down Expand Up @@ -428,7 +428,7 @@ mod tests {
snapshot_package_output_path: PathBuf::from("/"),
snapshot_path: PathBuf::from("/"),
compression: CompressionType::Bzip2,
snapshot_version: SnapshotVersion::default(),
snapshot_version: SnapshotVersion::default(),
}),
cluster_info,
None,
Expand Down
8 changes: 3 additions & 5 deletions core/src/snapshot_packager_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ mod tests {
use solana_ledger::bank_forks::CompressionType;
use solana_ledger::{
snapshot_package::AccountsPackage,
snapshot_utils::{self, SNAPSHOT_STATUS_CACHE_FILE_NAME, SnapshotVersion},
};
use solana_runtime::{
accounts_db::AccountStorageEntry, bank::BankSlotDelta,
snapshot_utils::{self, SnapshotVersion, SNAPSHOT_STATUS_CACHE_FILE_NAME},
};
use solana_runtime::{accounts_db::AccountStorageEntry, bank::BankSlotDelta};
use solana_sdk::hash::Hash;
use std::{
fs::{self, remove_dir_all, OpenOptions},
Expand Down Expand Up @@ -175,7 +173,7 @@ mod tests {
output_tar_path.clone(),
Hash::default(),
CompressionType::Bzip2,
SnapshotVersion::default(),
SnapshotVersion::default(),
);

// Make tarball from packageable snapshot
Expand Down
24 changes: 19 additions & 5 deletions core/tests/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod tests {
snapshot_package_output_path: PathBuf::from(snapshot_output_path.path()),
snapshot_path: PathBuf::from(snapshot_dir.path()),
compression: CompressionType::Bzip2,
snapshot_version: snapshot_utils::SnapshotVersion::default(),
snapshot_version: snapshot_utils::SnapshotVersion::default(),
};
bank_forks.set_snapshot_config(Some(snapshot_config.clone()));
SnapshotTestConfig {
Expand Down Expand Up @@ -129,7 +129,11 @@ mod tests {
let accounts_dir = &snapshot_test_config.accounts_dir;
let snapshot_config = &snapshot_test_config.snapshot_config;
let mint_keypair = &snapshot_test_config.genesis_config_info.mint_keypair;
let snapshot_version = bank_forks.snapshot_config.as_ref().unwrap().snapshot_version;
let snapshot_version = bank_forks
.snapshot_config
.as_ref()
.unwrap()
.snapshot_version;

let (s, _r) = channel();
let sender = Some(s);
Expand Down Expand Up @@ -159,7 +163,7 @@ mod tests {
&snapshot_config.snapshot_package_output_path,
storages,
CompressionType::Bzip2,
snapshot_version,
snapshot_version,
)
.unwrap();

Expand Down Expand Up @@ -220,12 +224,22 @@ mod tests {
let snapshot_config = &snapshot_test_config.snapshot_config;
let mint_keypair = &snapshot_test_config.genesis_config_info.mint_keypair;
let genesis_config = &snapshot_test_config.genesis_config_info.genesis_config;
let snapshot_version = bank_forks.snapshot_config.as_ref().unwrap().snapshot_version;
let snapshot_version = bank_forks
.snapshot_config
.as_ref()
.unwrap()
.snapshot_version;

// Take snapshot of zeroth bank
let bank0 = bank_forks.get(0).unwrap();
let storages: Vec<_> = bank0.get_snapshot_storages();
snapshot_utils::add_snapshot(&snapshot_config.snapshot_path, bank0, &storages, snapshot_version).unwrap();
snapshot_utils::add_snapshot(
&snapshot_config.snapshot_path,
bank0,
&storages,
snapshot_version,
)
.unwrap();

// Set up snapshotting channels
let (sender, receiver) = channel();
Expand Down
26 changes: 16 additions & 10 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ fn load_bank_forks(
snapshot_package_output_path: ledger_path.clone(),
snapshot_path: ledger_path.clone().join("snapshot"),
compression: CompressionType::Bzip2,
snapshot_version: snapshot_utils::SnapshotVersion::default(),
snapshot_version: snapshot_utils::SnapshotVersion::default(),
})
};
let account_paths = if let Some(account_paths) = arg_matches.value_of("account_paths") {
Expand Down Expand Up @@ -632,9 +632,11 @@ fn main() {
let snapshot_version_arg = Arg::with_name("snapshot_version")
.long("snapshot-version")
.value_name("VERSION")
.validator(|arg| arg.parse::<snapshot_utils::SnapshotVersion>()
.map(|_| ())
.map_err(|e| e.to_string()))
.validator(|arg| {
arg.parse::<snapshot_utils::SnapshotVersion>()
.map(|_| ())
.map_err(|e| e.to_string())
})
.multiple(false)
.required(false)
.takes_value(true)
Expand Down Expand Up @@ -1026,11 +1028,15 @@ fn main() {
("create-snapshot", Some(arg_matches)) => {
let snapshot_slot = value_t_or_exit!(arg_matches, "snapshot_slot", Slot);
let output_directory = value_t_or_exit!(arg_matches, "output_directory", String);
let snapshot_version = match arg_matches.value_of("snapshot_version") {
Some(s) => s.parse::<snapshot_utils::SnapshotVersion>()
.unwrap_or_else(|e| { eprintln!("Error: {}", e); exit(1) }),
None => snapshot_utils::SnapshotVersion::default(),
};
let snapshot_version = match arg_matches.value_of("snapshot_version") {
Some(s) => s
.parse::<snapshot_utils::SnapshotVersion>()
.unwrap_or_else(|e| {
eprintln!("Error: {}", e);
exit(1)
}),
None => snapshot_utils::SnapshotVersion::default(),
};
let process_options = ProcessOptions {
dev_halt_at_slot: Some(snapshot_slot),
new_hard_forks: hardforks_of(arg_matches, "hard_forks"),
Expand Down Expand Up @@ -1064,7 +1070,7 @@ fn main() {
output_directory,
storages,
CompressionType::Bzip2,
snapshot_version,
snapshot_version,
)
})
.and_then(|package| {
Expand Down
9 changes: 7 additions & 2 deletions ledger/src/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,12 @@ impl BankForks {

let storages: Vec<_> = bank.get_snapshot_storages();
let mut add_snapshot_time = Measure::start("add-snapshot-ms");
snapshot_utils::add_snapshot(&config.snapshot_path, &bank, &storages, config.snapshot_version)?;
snapshot_utils::add_snapshot(
&config.snapshot_path,
&bank,
&storages,
config.snapshot_version,
)?;
add_snapshot_time.stop();
inc_new_counter_info!("add-snapshot-ms", add_snapshot_time.as_ms() as usize);

Expand All @@ -343,7 +348,7 @@ impl BankForks {
&config.snapshot_package_output_path,
storages,
config.compression.clone(),
config.snapshot_version,
config.snapshot_version,
)?;

accounts_package_sender.send(package)?;
Expand Down
4 changes: 2 additions & 2 deletions ledger/src/snapshot_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl AccountsPackage {
tar_output_file: PathBuf,
hash: Hash,
compression: CompressionType,
snapshot_version: SnapshotVersion,
snapshot_version: SnapshotVersion,
) -> Self {
Self {
root,
Expand All @@ -47,7 +47,7 @@ impl AccountsPackage {
tar_output_file,
hash,
compression,
snapshot_version,
snapshot_version,
}
}
}
Loading

0 comments on commit c52f79e

Please sign in to comment.