Skip to content

Commit b8c3b28

Browse files
authored
protocols/gossipsub: Allow publishing to anything that implements Into<TopicHash> (#2862)
1 parent f04df29 commit b8c3b28

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

protocols/gossipsub/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
- Update to `libp2p-swarm` `v0.39.0`.
44

5+
- Allow publishing with any `impl Into<TopicHash>` as a topic. See [PR 2862].
6+
7+
[PR 2862]: https://github.com/libp2p/rust-libp2p/pull/2862
8+
59
# 0.40.0
610

711
- Update prost requirement from 0.10 to 0.11 which no longer installs the protoc Protobuf compiler.

protocols/gossipsub/src/behaviour.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,19 +587,20 @@ where
587587
}
588588

589589
/// Publishes a message with multiple topics to the network.
590-
pub fn publish<H: Hasher>(
590+
pub fn publish(
591591
&mut self,
592-
topic: Topic<H>,
592+
topic: impl Into<TopicHash>,
593593
data: impl Into<Vec<u8>>,
594594
) -> Result<MessageId, PublishError> {
595595
let data = data.into();
596+
let topic = topic.into();
596597

597598
// Transform the data before building a raw_message.
598599
let transformed_data = self
599600
.data_transform
600-
.outbound_transform(&topic.hash(), data.clone())?;
601+
.outbound_transform(&topic, data.clone())?;
601602

602-
let raw_message = self.build_raw_message(topic.into(), transformed_data)?;
603+
let raw_message = self.build_raw_message(topic, transformed_data)?;
603604

604605
// calculate the message id from the un-transformed data
605606
let msg_id = self.config.message_id(&GossipsubMessage {

0 commit comments

Comments
 (0)