Skip to content

Commit

Permalink
Only show import log when import is successful
Browse files Browse the repository at this point in the history
  • Loading branch information
chong-he committed Sep 20, 2024
1 parent 779eca1 commit 3e97c75
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions validator_client/src/http_api/keystores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ pub fn import<T: SlotClock + 'static, E: EthSpec>(
)));
}

info!(
log,
"Importing keystores via standard HTTP API";
"count" => request.keystores.len(),
);

// Import slashing protection data before keystores, so that new keystores don't start signing
// without it. Do not return early on failure, propagate the failure to each key.
let slashing_protection_status =
Expand Down Expand Up @@ -156,6 +150,21 @@ pub fn import<T: SlotClock + 'static, E: EthSpec>(
statuses.push(status);
}

let successful_import = statuses
.iter()
.filter(|status| matches!(status.status, ImportKeystoreStatus::Imported))
.count();

if successful_import > 0 {
info!(
log,
"Imported keystores via standard HTTP API";
"count" => successful_import,
);
}

println!("testing");

Ok(ImportKeystoresResponse { data: statuses })
}

Expand Down Expand Up @@ -241,17 +250,17 @@ pub fn delete<T: SlotClock + 'static, E: EthSpec>(
let export_response = export(request, validator_store, task_executor, log.clone())?;

// Check the status is Deleted to confirm deletion is successful, then only display the log
let successful_deletion: Vec<_> = export_response
let successful_deletion = export_response
.data
.iter()
.filter(|response| matches!(response.status.status, DeleteKeystoreStatus::Deleted))
.collect();
.count();

if !successful_deletion.is_empty() {
if successful_deletion > 0 {
info!(
log,
"Deleted keystore via standard HTTP API";
"count" => successful_deletion.len(),
"count" => successful_deletion,
);
}

Expand Down

0 comments on commit 3e97c75

Please sign in to comment.