Rework ConnectionsRequests (#2081)

* Rework `ConnectionsRequests`

Instead of implementing the `Stream` trait, this struct now provides a
function `next()`. This enables us to encode into the type system that
it will always return a value or block indefinitely.

* Review feedback
This commit is contained in:
Bastian Köcher
2020-12-07 18:47:31 +01:00
committed by GitHub
parent 52537f3621
commit 79a5b12dc1
3 changed files with 102 additions and 96 deletions
@@ -700,14 +700,7 @@ impl PoVDistribution {
// peer view update messages may be racy and we want connection notifications
// first.
futures::select_biased! {
v = state.connection_requests.next() => {
match v {
Some((_relay_parent, _validator_id, peer_id)) => {
handle_validator_connected(&mut state, peer_id);
}
None => break,
}
}
v = state.connection_requests.next().fuse() => handle_validator_connected(&mut state, v.peer_id),
v = ctx.recv().fuse() => {
match v? {
FromOverseer::Signal(signal) => if handle_signal(
@@ -743,10 +736,8 @@ impl PoVDistribution {
}
}
}
};
}
}
Ok(())
}
}