From 828f7af5a9e24238e089fb34065f5856af916460 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 3 Nov 2023 16:02:59 +0100 Subject: [PATCH] Avoid cloning the proposal --- Code/consensus/src/executor.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Code/consensus/src/executor.rs b/Code/consensus/src/executor.rs index ea9d23c4c..46e2b0769 100644 --- a/Code/consensus/src/executor.rs +++ b/Code/consensus/src/executor.rs @@ -146,7 +146,6 @@ where fn apply_proposal(&mut self, proposal: Ctx::Proposal) -> Option> { // TODO: Check for invalid proposal - let event = RoundEvent::Proposal(proposal.clone()); // Check that there is an ongoing round let Some(round_state) = self.round_states.get(&self.round) else { @@ -176,7 +175,9 @@ where Round::Nil => { // Is it possible to get +2/3 prevotes before the proposal? // Do we wait for our own prevote to check the threshold? - self.apply_event(proposal.round(), event) + let round = proposal.round(); + let event = RoundEvent::Proposal(proposal); + self.apply_event(round, event) } Round::Some(_) if self.votes.is_threshold_met( @@ -185,7 +186,9 @@ where Threshold::Value(proposal.value().id()), ) => { - self.apply_event(proposal.round(), event) + let round = proposal.round(); + let event = RoundEvent::Proposal(proposal); + self.apply_event(round, event) } _ => None, }