Check and unwrap() Option instead of .iter().for_each() (#21072)

This commit is contained in:
Brooks Prumo 2021-10-29 14:17:03 -05:00 committed by GitHub
parent 91c49d7023
commit 1453fce6c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -1150,13 +1150,15 @@ mod with_incremental_snapshots {
cluster_info: &ClusterInfo,
validator_config: &ValidatorConfig,
) -> HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> {
if validator_config.trusted_validators.is_none() {
trace!("no trusted validators, so no trusted snapshot hashes");
return HashMap::new();
}
let trusted_validators = validator_config.trusted_validators.as_ref().unwrap();
let mut trusted_snapshot_hashes: HashMap<(Slot, Hash), HashSet<(Slot, Hash)>> =
HashMap::new();
validator_config
.trusted_validators
.iter()
.for_each(|trusted_validators| {
trusted_validators
trusted_validators
.iter()
.for_each(|trusted_validator| {
if let Some(crds_value::IncrementalSnapshotHashes {base: full_snapshot_hash, hashes: incremental_snapshot_hashes, ..}) = cluster_info.get_incremental_snapshot_hashes_for_node(trusted_validator) {
@ -1197,8 +1199,7 @@ mod with_incremental_snapshots {
}
}
}
})
});
});
trace!("trusted snapshot hashes: {:?}", &trusted_snapshot_hashes);
trusted_snapshot_hashes