diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index 48993c987fb..7fa96a4748f 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -2,6 +2,10 @@ - Update to `libp2p-swarm` `v0.39.0`. +- Allow publishing with any `impl Into` as a topic. See [PR 2862]. + +[PR 2862]: https://github.com/libp2p/rust-libp2p/pull/2862 + # 0.40.0 - Update prost requirement from 0.10 to 0.11 which no longer installs the protoc Protobuf compiler. diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index 900e1b43be4..954c68ae24b 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -587,19 +587,20 @@ where } /// Publishes a message with multiple topics to the network. - pub fn publish( + pub fn publish( &mut self, - topic: Topic, + topic: impl Into, data: impl Into>, ) -> Result { let data = data.into(); + let topic = topic.into(); // Transform the data before building a raw_message. let transformed_data = self .data_transform - .outbound_transform(&topic.hash(), data.clone())?; + .outbound_transform(&topic, data.clone())?; - let raw_message = self.build_raw_message(topic.into(), transformed_data)?; + let raw_message = self.build_raw_message(topic, transformed_data)?; // calculate the message id from the un-transformed data let msg_id = self.config.message_id(&GossipsubMessage {