mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-14 18:41:22 +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
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
- Update to `libp2p-swarm` `v0.39.0`.
|
- Update to `libp2p-swarm` `v0.39.0`.
|
||||||
|
|
||||||
|
- Allow publishing with any `impl Into<TopicHash>` as a topic. See [PR 2862].
|
||||||
|
|
||||||
|
[PR 2862]: https://github.com/libp2p/rust-libp2p/pull/2862
|
||||||
|
|
||||||
# 0.40.0
|
# 0.40.0
|
||||||
|
|
||||||
- Update prost requirement from 0.10 to 0.11 which no longer installs the protoc Protobuf compiler.
|
- Update prost requirement from 0.10 to 0.11 which no longer installs the protoc Protobuf compiler.
|
||||||
|
@ -587,19 +587,20 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Publishes a message with multiple topics to the network.
|
/// Publishes a message with multiple topics to the network.
|
||||||
pub fn publish<H: Hasher>(
|
pub fn publish(
|
||||||
&mut self,
|
&mut self,
|
||||||
topic: Topic<H>,
|
topic: impl Into<TopicHash>,
|
||||||
data: impl Into<Vec<u8>>,
|
data: impl Into<Vec<u8>>,
|
||||||
) -> Result<MessageId, PublishError> {
|
) -> Result<MessageId, PublishError> {
|
||||||
let data = data.into();
|
let data = data.into();
|
||||||
|
let topic = topic.into();
|
||||||
|
|
||||||
// Transform the data before building a raw_message.
|
// Transform the data before building a raw_message.
|
||||||
let transformed_data = self
|
let transformed_data = self
|
||||||
.data_transform
|
.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
|
// calculate the message id from the un-transformed data
|
||||||
let msg_id = self.config.message_id(&GossipsubMessage {
|
let msg_id = self.config.message_id(&GossipsubMessage {
|
||||||
|
Reference in New Issue
Block a user