mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: Add PeerEvent to NetworkEvent enum (#574)
* Add peerAdded and peerRemoved events to NetworkEvent enum * Remove unnecessary todo macros
This commit is contained in:
@ -65,6 +65,12 @@ async fn test_establish_connections() {
|
||||
NetworkEvent::SessionEstablished { peer_id, .. } => {
|
||||
assert!(expected_connections.remove(&peer_id))
|
||||
}
|
||||
NetworkEvent::PeerAdded(peer_id) => {
|
||||
assert!(!expected_connections.contains(&peer_id))
|
||||
}
|
||||
NetworkEvent::PeerRemoved(_) => {
|
||||
panic!("unexpected event")
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(expected_connections.is_empty());
|
||||
|
||||
@ -308,7 +308,7 @@ impl NetworkEventStream {
|
||||
while let Some(ev) = self.inner.next().await {
|
||||
match ev {
|
||||
NetworkEvent::SessionClosed { peer_id, reason } => return Some((peer_id, reason)),
|
||||
NetworkEvent::SessionEstablished { .. } => continue,
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
None
|
||||
@ -317,8 +317,8 @@ impl NetworkEventStream {
|
||||
pub async fn next_session_established(&mut self) -> Option<PeerId> {
|
||||
while let Some(ev) = self.inner.next().await {
|
||||
match ev {
|
||||
NetworkEvent::SessionClosed { .. } => continue,
|
||||
NetworkEvent::SessionEstablished { peer_id, .. } => return Some(peer_id),
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user