Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(network): make streamhashmap not end #2249

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions crates/papyrus_network/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl<K: Unpin + Clone + Eq + Hash, V: Stream + Unpin> StreamHashMap<K, V> {
}

pub fn insert(&mut self, key: K, value: V) -> Option<V> {
self.finished_streams.remove(&key);
self.map.insert(key, value)
}
}
Expand All @@ -45,7 +46,6 @@ impl<K: Unpin + Clone + Eq + Hash, V: Stream + Unpin> Stream for StreamHashMap<K

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let unpinned_self = Pin::into_inner(self);
let mut finished = true;
for (key, stream) in &mut unpinned_self.map {
match stream.poll_next_unpin(cx) {
Poll::Ready(Some(value)) => {
Expand All @@ -54,15 +54,9 @@ impl<K: Unpin + Clone + Eq + Hash, V: Stream + Unpin> Stream for StreamHashMap<K
Poll::Ready(None) => {
unpinned_self.finished_streams.insert(key.clone());
}
Poll::Pending => {
finished = false;
}
Poll::Pending => {}
}
}
if finished {
// TODO(shahak): Make StreamHashMap not end in order to accept new inserted streams.
return Poll::Ready(None);
}
Poll::Pending
}
}
Loading