Struct litep2p::protocol::notification::ConfigBuilder
source · pub struct ConfigBuilder { /* private fields */ }
Expand description
Notification configuration builder.
Implementations§
source§impl ConfigBuilder
impl ConfigBuilder
sourcepub fn new(protocol_name: ProtocolName) -> Self
pub fn new(protocol_name: ProtocolName) -> Self
Create new ConfigBuilder
.
sourcepub fn with_max_size(self, max_notification_size: usize) -> Self
pub fn with_max_size(self, max_notification_size: usize) -> Self
Set maximum notification size.
sourcepub fn with_handshake(self, handshake: Vec<u8>) -> Self
pub fn with_handshake(self, handshake: Vec<u8>) -> Self
Set handshake.
sourcepub fn with_fallback_names(self, fallback_names: Vec<ProtocolName>) -> Self
pub fn with_fallback_names(self, fallback_names: Vec<ProtocolName>) -> Self
Set fallback names.
sourcepub fn with_auto_accept_inbound(self, auto_accept: bool) -> Self
pub fn with_auto_accept_inbound(self, auto_accept: bool) -> Self
Auto-accept inbound substreams for those connections which were initiated by the local node.
Connection in this context means a bidirectional substream pair between two peers over a given protocol.
By default, when a node starts a connection with a remote node and opens an outbound substream to them, that substream is validated and if it’s accepted, remote node sends their handshake over that substream and opens another substream to local node. The substream that was opened by the local node is used for sending data and the one opened by the remote node is used for receiving data.
By default, even if the local node was the one that opened the first substream, this inbound substream coming from remote node must be validated as the handshake of the remote node may reveal that it’s not someone that the local node is willing to accept.
To disable this behavior, auto accepting for the inbound substream can be enabled. If local
node is the one that opened the connection and it was accepted by the remote node, local
node is only notified via
NotificationStreamOpened
.
sourcepub fn with_sync_channel_size(self, size: usize) -> Self
pub fn with_sync_channel_size(self, size: usize) -> Self
Configure size of the channel for sending synchronous notifications.
Default value is 16
.
sourcepub fn with_async_channel_size(self, size: usize) -> Self
pub fn with_async_channel_size(self, size: usize) -> Self
Configure size of the channel for sending asynchronous notifications.
Default value is 8
.
sourcepub fn with_dialing_enabled(self, should_dial: bool) -> Self
pub fn with_dialing_enabled(self, should_dial: bool) -> Self
Should NotificationProtocol
attempt to dial the peer if an outbound substream is opened
but no connection to the peer exist.
Dialing is enabled by default.
sourcepub fn build(self) -> (Config, NotificationHandle)
pub fn build(self) -> (Config, NotificationHandle)
Build notification configuration.