mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-12 01:21:21 +00:00
protocols/gossipsub: Allow publishing to anything that implements Into<TopicHash>
(#2862)
This commit is contained in:
committed by
GitHub
parent
f04df2901b
commit
b8c3b282ee
@ -587,19 +587,20 @@ where
|
||||
}
|
||||
|
||||
/// Publishes a message with multiple topics to the network.
|
||||
pub fn publish<H: Hasher>(
|
||||
pub fn publish(
|
||||
&mut self,
|
||||
topic: Topic<H>,
|
||||
topic: impl Into<TopicHash>,
|
||||
data: impl Into<Vec<u8>>,
|
||||
) -> Result<MessageId, PublishError> {
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user