diff options
author | hozan23 <hozan23@karyontech.net> | 2024-05-22 18:02:51 +0200 |
---|---|---|
committer | hozan23 <hozan23@karyontech.net> | 2024-05-22 18:02:51 +0200 |
commit | 5df6812dd2254b871eb773dc626b89646ca87495 (patch) | |
tree | 18828be9c86aba205d30086f705f2c6e2aeee975 /p2p/src/discovery/lookup.rs | |
parent | c2860d3266aa1233787400b163d527fdc7dafe61 (diff) |
p2p: monitor system use core::EventSys instead of pubsub pattern
Diffstat (limited to 'p2p/src/discovery/lookup.rs')
-rw-r--r-- | p2p/src/discovery/lookup.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/p2p/src/discovery/lookup.rs b/p2p/src/discovery/lookup.rs index cff4610..613c3cd 100644 --- a/p2p/src/discovery/lookup.rs +++ b/p2p/src/discovery/lookup.rs @@ -134,7 +134,7 @@ impl LookupService { pub async fn start_lookup(&self, endpoint: &Endpoint, peer_id: Option<PeerID>) -> Result<()> { trace!("Lookup started {endpoint}"); self.monitor - .notify(&DiscoveryEvent::LookupStarted(endpoint.clone()).into()) + .notify(DiscoveryEvent::LookupStarted(endpoint.clone())) .await; let mut random_peers = vec![]; @@ -143,7 +143,7 @@ impl LookupService { .await { self.monitor - .notify(&DiscoveryEvent::LookupFailed(endpoint.clone()).into()) + .notify(DiscoveryEvent::LookupFailed(endpoint.clone())) .await; return Err(err); }; @@ -166,7 +166,10 @@ impl LookupService { drop(table); self.monitor - .notify(&DiscoveryEvent::LookupSucceeded(endpoint.clone(), peer_buffer.len()).into()) + .notify(DiscoveryEvent::LookupSucceeded( + endpoint.clone(), + peer_buffer.len(), + )) .await; Ok(()) @@ -230,10 +233,14 @@ impl LookupService { target_peer_id: &PeerID, ) -> Result<Vec<PeerMsg>> { let conn = self.connector.connect(&endpoint, &peer_id).await?; + self.monitor + .notify(DiscoveryEvent::Conn(ConnEvent::Connected(endpoint.clone()))) + .await; + let result = self.handle_outbound(conn, target_peer_id).await; self.monitor - .notify(&ConnEvent::Disconnected(endpoint).into()) + .notify(DiscoveryEvent::Conn(ConnEvent::Disconnected(endpoint))) .await; self.outbound_slots.remove().await; |