From df7d54e9d9df645fb7091626b723949866fe5a2a Mon Sep 17 00:00:00 2001 From: zghh <1069308575@qq.com> Date: Thu, 16 Nov 2023 22:20:41 +0800 Subject: [PATCH] fix(gossipsub): send iwant messages immediately --- protocols/gossipsub/src/behaviour.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index 0780ca657db..5a9329964d5 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -1306,13 +1306,22 @@ where iwant_ids_vec ); - Self::control_pool_add( - &mut self.control_pool, - *peer_id, - ControlAction::IWant { - message_ids: iwant_ids_vec, - }, - ); + if self + .send_message( + *peer_id, + Rpc { + subscriptions: Vec::new(), + messages: Vec::new(), + control_msgs: vec![ControlAction::IWant { + message_ids: iwant_ids_vec, + }], + } + .into_protobuf(), + ) + .is_err() + { + tracing::error!("IHAVE: Failed to send message asking to peer"); + } } tracing::trace!(peer=%peer_id, "Completed IHAVE handling for peer"); }