Use type alias for DownloadProgress callback (#17518)

Convert to use type alias for the callback and cascade the changes to callers. Thanks @jeffwashington for the help making it possible.
Changed the closure for the progress update in the validator main to FnMut and modify the abort count in the closure which is more reliable.
This commit is contained in:
Lijun Wang
2021-05-26 13:26:07 -07:00
committed by GitHub
parent 6abe089740
commit 54f0fc9f0f
4 changed files with 24 additions and 40 deletions

View File

@ -4,7 +4,7 @@ use {
crate_description, crate_name, crate_version, value_t, value_t_or_exit, values_t, App, Arg,
},
regex::Regex,
solana_download_utils::{download_file, DownloadProgressRecord},
solana_download_utils::download_file,
solana_sdk::signature::{write_keypair_file, Keypair},
std::{
collections::HashMap,
@ -112,12 +112,7 @@ fn install_if_missing(
url.push_str(version);
url.push('/');
url.push_str(file.to_str().unwrap());
download_file(
&url.as_str(),
&file,
true,
&None::<fn(&DownloadProgressRecord) -> bool>,
)?;
download_file(&url.as_str(), &file, true, &mut None)?;
fs::create_dir_all(&target_path).map_err(|err| err.to_string())?;
let zip = File::open(&file).map_err(|err| err.to_string())?;
let tar = BzDecoder::new(BufReader::new(zip));