Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ancazamfir committed Nov 4, 2023
1 parent dc5a1a5 commit 9c4f56e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Code/consensus/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ where
RoundEvent::NewRound
};

assert!(self.round < round);
self.round_states
.insert(round, RoundState::default().new_round(round));
self.round = round;

self.apply_event(round, event)
}

Expand Down Expand Up @@ -229,7 +234,7 @@ where
/// Apply the event, update the state.
fn apply_event(&mut self, round: Round, event: RoundEvent<Ctx>) -> Option<RoundMessage<Ctx>> {
// Get the round state, or create a new one
let mut round_state = self.round_states.remove(&round).unwrap_or_default();
let round_state = self.round_states.remove(&round).unwrap_or_default();

let data = RoundData::new(round, &self.height, &self.address);

Expand All @@ -247,14 +252,7 @@ where
}
_ => RoundEvent::PrecommitAny,
},
RoundEvent::NewRound | RoundEvent::NewRoundProposer(_) => {
assert!(self.round < round);
self.round_states
.insert(round, RoundState::default().new_round(round));
self.round = round;
round_state.round = round;
event
}

_ => event,
};

Expand Down

0 comments on commit 9c4f56e

Please sign in to comment.