diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index b143b72c15c..dba3d12e879 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -19,13 +19,16 @@ - Fix incorrect default values in ConfigBuilder See [PR 6113](https://github.com/libp2p/rust-libp2p/pull/6113) - + - Remove duplicated config `set_topic_max_transmit_size` method, prefer `max_transmit_size_for_topic`. See [PR 6173](https://github.com/libp2p/rust-libp2p/pull/6173). - Switch the internal `async-channel` used to dispatch messages from `NetworkBehaviour` to the `ConnectionHandler` with an internal priority queue. See [PR 6175](https://github.com/libp2p/rust-libp2p/pull/6175) +- gossipsub: do early return in for an empty input + See [PR 6208](https://github.com/libp2p/rust-libp2p/pull/6208). + ## 0.49.2 - Relax `Behaviour::with_metrics` requirements, do not require DataTransform and TopicSubscriptionFilter to also impl Default diff --git a/protocols/gossipsub/src/queue.rs b/protocols/gossipsub/src/queue.rs index ff04392e618..971ae801f83 100644 --- a/protocols/gossipsub/src/queue.rs +++ b/protocols/gossipsub/src/queue.rs @@ -81,6 +81,10 @@ impl Queue { /// Remove pending low priority Publish and Forward messages. /// Returns the number of messages removed. pub(crate) fn remove_data_messages(&mut self, message_ids: &[MessageId]) -> usize { + if message_ids.is_empty() { + return 0; + } + let mut count = 0; self.non_priority.retain(|message| match message { RpcOut::Publish { message_id, .. } | RpcOut::Forward { message_id, .. } => {