diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index c462a4dd448..4a5013ba1b7 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -5,6 +5,8 @@ - Improve `max_messages_per_rpc` consistency by ensuring RPC control messages also adhere to the existing limits. See [PR 5826](https://github.com/libp2p/rust-libp2p/pull/5826) +- Create `DEFAULT_MAX_TRANSMIT_SIZE` and use it in the code and docs. The main motivation is to fix the incorrect value mentioned in the docs and prevent it from happening again. See [PR 5906](https://github.com/libp2p/rust-libp2p/pull/5906) + ## 0.48.0 - Allow broadcasting `IDONTWANT` messages when publishing to avoid downloading data that is already available. diff --git a/protocols/gossipsub/src/config.rs b/protocols/gossipsub/src/config.rs index d524ed78cc0..7397b4e8da6 100644 --- a/protocols/gossipsub/src/config.rs +++ b/protocols/gossipsub/src/config.rs @@ -177,7 +177,8 @@ impl Config { self.check_explicit_peers_ticks } - /// The maximum byte size for each gossipsub RPC (default is 65536 bytes). + /// The maximum byte size for each gossipsub RPC (default is + /// [`crate::protocol::DEFAULT_MAX_TRANSMIT_SIZE`] bytes). /// /// This represents the maximum size of the published message. It is additionally wrapped /// in a protobuf struct, so the actual wire size may be a bit larger. It must be at least @@ -619,7 +620,8 @@ impl ConfigBuilder { self } - /// The maximum byte size for each gossip (default is 2048 bytes). + /// The maximum byte size for each gossip (default is + /// [`crate::protocol::DEFAULT_MAX_TRANSMIT_SIZE`] bytes). pub fn max_transmit_size(&mut self, max_transmit_size: usize) -> &mut Self { self.config.protocol.max_transmit_size = max_transmit_size; self diff --git a/protocols/gossipsub/src/lib.rs b/protocols/gossipsub/src/lib.rs index 87db1b771d1..a61babf2900 100644 --- a/protocols/gossipsub/src/lib.rs +++ b/protocols/gossipsub/src/lib.rs @@ -136,3 +136,5 @@ pub type Rpc = self::types::Rpc; pub type IdentTopic = Topic; pub type Sha256Topic = Topic; + +pub use crate::protocol::DEFAULT_MAX_TRANSMIT_SIZE; diff --git a/protocols/gossipsub/src/protocol.rs b/protocols/gossipsub/src/protocol.rs index 7ee6d5c8245..4a9faf0b24f 100644 --- a/protocols/gossipsub/src/protocol.rs +++ b/protocols/gossipsub/src/protocol.rs @@ -61,6 +61,8 @@ pub(crate) const FLOODSUB_PROTOCOL: ProtocolId = ProtocolId { kind: PeerKind::Floodsub, }; +pub const DEFAULT_MAX_TRANSMIT_SIZE: usize = 65536; + /// Implementation of [`InboundUpgrade`] and [`OutboundUpgrade`] for the Gossipsub protocol. #[derive(Debug, Clone)] pub struct ProtocolConfig { @@ -75,7 +77,7 @@ pub struct ProtocolConfig { impl Default for ProtocolConfig { fn default() -> Self { Self { - max_transmit_size: 65536, + max_transmit_size: DEFAULT_MAX_TRANSMIT_SIZE, validation_mode: ValidationMode::Strict, protocol_ids: vec![ GOSSIPSUB_1_2_0_PROTOCOL,