Skip to content

Commit

Permalink
fix(code/app): Fix bug in test app and example app where proposal par…
Browse files Browse the repository at this point in the history
…ts were not processed in order of sequence number (#851)
  • Loading branch information
romac authored Feb 14, 2025
1 parent 0449465 commit 8e7f30b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions code/crates/test/app/src/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ impl<T> MinHeap<T> {
}

fn drain(&mut self) -> Vec<T> {
self.0
.drain()
.filter_map(|msg| msg.0.content.into_data())
.collect()
let mut vec = Vec::with_capacity(self.0.len());
while let Some(MinSeq(msg)) = self.0.pop() {
if let Some(data) = msg.content.into_data() {
vec.push(data);
}
}
vec
}
}

Expand Down
11 changes: 7 additions & 4 deletions code/examples/channel/src/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ impl<T> MinHeap<T> {
}

fn drain(&mut self) -> Vec<T> {
self.0
.drain()
.filter_map(|msg| msg.0.content.into_data())
.collect()
let mut vec = Vec::with_capacity(self.0.len());
while let Some(MinSeq(msg)) = self.0.pop() {
if let Some(data) = msg.content.into_data() {
vec.push(data);
}
}
vec
}
}

Expand Down

0 comments on commit 8e7f30b

Please sign in to comment.