rearrange

This commit is contained in:
Tan Chee Keong
2025-04-11 19:37:46 +08:00
parent ea13f74c06
commit 44bd5f13f6

View File

@@ -1150,8 +1150,8 @@ async fn fill_in_selection_proofs<T: SlotClock + 'static, E: EthSpec>(
// In distributed case, we want to send all partial selection proofs to the middleware to determine aggregation duties,
// as the middleware will need to have a threshold of partial selection proofs to be able to return the full selection proof
// Thus, sign selection proofs in parallel in distributed case; Otherwise, sign them serially in non-distributed (normal) case
let duty_and_proof_results = if config.parallel_sign {
let mut futures = relevant_duties
if config.parallel_sign {
let mut duty_and_proof_results = relevant_duties
.into_values()
.flatten()
.map(|duty| async {
@@ -1167,7 +1167,7 @@ async fn fill_in_selection_proofs<T: SlotClock + 'static, E: EthSpec>(
})
.collect::<FuturesUnordered<_>>();
while let Some(result) = futures.next().await {
while let Some(result) = duty_and_proof_results.next().await {
let mut attesters = duties_service.attesters.write();
let (duty, selection_proof) = match result {
Ok(duty_and_proof) => duty_and_proof,
@@ -1233,9 +1233,8 @@ async fn fill_in_selection_proofs<T: SlotClock + 'static, E: EthSpec>(
}
}
}
Vec::new()
} else {
stream::iter(relevant_duties.into_values().flatten())
let duty_and_proof_results = stream::iter(relevant_duties.into_values().flatten())
.then(|duty| async {
let opt_selection_proof = make_selection_proof(
&duty,
@@ -1248,8 +1247,7 @@ async fn fill_in_selection_proofs<T: SlotClock + 'static, E: EthSpec>(
Ok((duty, opt_selection_proof))
})
.collect::<Vec<_>>()
.await
};
.await;
// Add to attesters store.
let mut attesters = duties_service.attesters.write();
@@ -1307,7 +1305,8 @@ async fn fill_in_selection_proofs<T: SlotClock + 'static, E: EthSpec>(
hash_map::Entry::Vacant(entry) => {
// This probably shouldn't happen, but we have enough info to fill in the
// entry so we may as well.
let subscription_slots = SubscriptionSlots::new(duty.slot, current_slot);
let subscription_slots =
SubscriptionSlots::new(duty.slot, current_slot);
let duty_and_proof = DutyAndProof {
duty,
selection_proof,
@@ -1318,6 +1317,7 @@ async fn fill_in_selection_proofs<T: SlotClock + 'static, E: EthSpec>(
}
}
drop(attesters);
};
let time_taken_ms =
Duration::from_secs_f64(timer.map_or(0.0, |t| t.stop_and_record())).as_millis();