From 2be910cd3973d990f7474a277814c565c956de3c Mon Sep 17 00:00:00 2001 From: boqiu <82121246@qq.com> Date: Fri, 22 Nov 2024 15:17:29 +0800 Subject: [PATCH] Notify peer connected to sync layer after status message exchanged --- node/router/src/libp2p_event_handler.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/node/router/src/libp2p_event_handler.rs b/node/router/src/libp2p_event_handler.rs index f418e53..2a02235 100644 --- a/node/router/src/libp2p_event_handler.rs +++ b/node/router/src/libp2p_event_handler.rs @@ -194,7 +194,6 @@ impl Libp2pEventHandler { if outgoing { self.send_status(peer_id); - self.send_to_sync(SyncMessage::PeerConnected { peer_id }); metrics::LIBP2P_HANDLE_PEER_CONNECTED_OUTGOING.mark(1); } else { metrics::LIBP2P_HANDLE_PEER_CONNECTED_INCOMING.mark(1); @@ -263,6 +262,8 @@ impl Libp2pEventHandler { return; } + self.send_to_sync(SyncMessage::PeerConnected { peer_id }); + let status_message = StatusMessage { data: network_id, num_shard: shard_config.num_shard, @@ -280,7 +281,9 @@ impl Libp2pEventHandler { fn on_status_response(&self, peer_id: PeerId, status: StatusMessage) { let network_id = self.network_globals.network_id(); let shard_config = self.store.get_store().get_shard_config(); - self.verify_status_message(peer_id, status, network_id, &shard_config); + if self.verify_status_message(peer_id, status, network_id, &shard_config) { + self.send_to_sync(SyncMessage::PeerConnected { peer_id }); + } } pub async fn on_rpc_response(