diff --git a/crates/sequencing/papyrus_consensus/src/lib.rs b/crates/sequencing/papyrus_consensus/src/lib.rs index a14bb0043c..ea8a7cf4d1 100644 --- a/crates/sequencing/papyrus_consensus/src/lib.rs +++ b/crates/sequencing/papyrus_consensus/src/lib.rs @@ -66,15 +66,17 @@ where } loop { - let message = current_height_messages.pop().unwrap_or( + let message = if let Some(msg) = current_height_messages.pop() { + msg + } else { // TODO(matan): Handle parsing failures and utilize ReportCallback. network_receiver .next() .await .expect("Network receiver closed unexpectedly") .0 - .expect("Failed to parse consensus message"), - ); + .expect("Failed to parse consensus message") + }; if message.height() != height.0 { debug!("Received a message for a different height. {:?}", message);