Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 5398b39

Browse files
committed
Log RPC node root slot
1 parent 6a5a638 commit 5398b39

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

validator/src/main.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,15 @@ fn download_file(url: &str, destination_file: &Path) -> Result<(), String> {
9393
let progress_bar = new_spinner_progress_bar();
9494
progress_bar.set_message(&format!("{}Downloading {}...", TRUCK, url));
9595

96-
let client = reqwest::blocking::Client::new();
97-
let response = client.get(url).send().map_err(|err| err.to_string())?;
96+
let response = reqwest::blocking::Client::new()
97+
.get(url)
98+
.send()
99+
.and_then(|response| response.error_for_status())
100+
.map_err(|err| {
101+
progress_bar.finish_and_clear();
102+
err.to_string()
103+
})?;
98104

99-
let response = response
100-
.error_for_status()
101-
.map_err(|err| format!("Unable to download {}: {}", url, err))?;
102105
let download_size = {
103106
response
104107
.headers()
@@ -139,9 +142,8 @@ fn download_file(url: &str, destination_file: &Path) -> Result<(), String> {
139142
response,
140143
};
141144

142-
let mut file = File::create(&temp_destination_file)
143-
.map_err(|err| format!("Unable to create {:?}: {:?}", temp_destination_file, err))?;
144-
std::io::copy(&mut source, &mut file)
145+
File::create(&temp_destination_file)
146+
.and_then(|mut file| std::io::copy(&mut source, &mut file))
145147
.map_err(|err| format!("Unable to write {:?}: {:?}", temp_destination_file, err))?;
146148

147149
source.progress_bar.finish_and_clear();
@@ -1138,7 +1140,12 @@ pub fn main() {
11381140
})
11391141
.and_then(|_| {
11401142
if let Some(snapshot_hash) = snapshot_hash {
1141-
download_snapshot(&rpc_contact_info.rpc, &ledger_path, snapshot_hash)
1143+
rpc_client.get_slot()
1144+
.map_err(|err| format!("Failed to get RPC node slot: {}", err))
1145+
.and_then(|slot| {
1146+
info!("RPC node root slot: {}", slot);
1147+
download_snapshot(&rpc_contact_info.rpc, &ledger_path, snapshot_hash)
1148+
})
11421149
} else {
11431150
Ok(())
11441151
}

0 commit comments

Comments
 (0)