Skip to content
Open
16 changes: 16 additions & 0 deletions code/crates/core-driver/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,22 @@ where
.get_proposal_and_validity_for_round_and_value(round, value_id)
}

/// Returns a valid proposal for the given round and value_id, if any.
pub fn valid_proposal_for_round_and_value(
&self,
round: Round,
value_id: ValueId<Ctx>,
) -> Option<&SignedProposal<Ctx>> {
if let Some((proposal, validity)) =
self.proposal_and_validity_for_round_and_value(round, value_id)
{
if validity.is_valid() {
return Some(proposal);
}
}
None
}

/// Returns the proposals and their validities for the given round, if any.
pub fn proposals_and_validities_for_round(
&self,
Expand Down
17 changes: 7 additions & 10 deletions code/crates/core-driver/src/mux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,14 @@ where
VKOutput::PrecommitAny => (threshold_round, RoundInput::PrecommitAny),
VKOutput::SkipRound(r) => (threshold_round, RoundInput::SkipRound(r)),
VKOutput::PrecommitValue(v) => {
if let Some((proposal, validity)) =
self.proposal_and_validity_for_round_and_value(threshold_round, v)
if let Some(proposal) = self.valid_proposal_for_round_and_value(threshold_round, v)
{
if validity.is_valid() {
(
threshold_round,
RoundInput::ProposalAndPrecommitValue(proposal.message.clone()),
)
} else {
(threshold_round, RoundInput::PrecommitAny)
}
(
threshold_round,
RoundInput::ProposalAndPrecommitValue(proposal.message.clone()),
)
} else if threshold_round > self.round() {
(threshold_round, RoundInput::SkipRound(threshold_round))
} else {
(threshold_round, RoundInput::PrecommitAny)
}
Expand Down
Loading
Loading