- Use
web-time
instead ofinstant
. See PR 5347.
- Allow
NetworkBehaviour
s to share addresses of peers. This is enabled via the newToSwarm::NewExternalAddrOfPeer
event. The address is broadcast to all behaviours viaFromSwarm::NewExternalAddrOfPeer
. Protocols that want to collect these addresses can use the newPeerAddresses
utility. See PR 4371.
- Implement
Clone
&Copy
for `FromSwarm. This makes it easier to forward these events when wrapping other behaviours. See PR 4825.
- Add
#[non_exhaustive]
toFromSwarm
,ToSwarm
,SwarmEvent
,ConnectionHandlerEvent
,ConnectionEvent
. See PR 4581. - Remove
handler
field fromConnectionClosed
. If you need to transfer state from aConnectionHandler
to itsNetworkBehaviour
when a connection closes, useConnectionHandler::poll_close
. See PR 4076. - Remove deprecated
PollParameters
fromNetworkBehaviour::poll
function. See PR 4490. - Remove deprecated
ConnectionHandlerEvent::Close
andConnectionHandler::Error
.ConnectionHandler
s should not close connections directly as the connection might still be in use by other handlers. See PR 4755. - Add
PeerCondition::DisconnectedAndNotDialing
variant, combining pre-existing conditions. This is the new default. A new dialing attempt is iniated only if the peer is both considered disconnected and there is currently no ongoing dialing attempt. See PR 4225. - Remove deprecated
keep_alive_timeout
inOneShotHandlerConfig
. See PR 4677. - Don't close entire connection upon
DialUpgradeError
s withinOneShotHandler
. Instead, the error is reported asErr(e)
viaConnectionHandler::ToBehaviour
. See PR 4715. - Log
PeerId
ofSwarm
even when constructed with newSwarmBuilder
. See PR 4671. - Add
SwarmEvent::{NewExternalAddrCandidate,ExternalAddrConfirmed,ExternalAddrExpired}
variants. See PR 4721. - Remove deprecated symbols. See PR 4737.
- Deprecate
ConnectionHandlerEvent::Close
. See issue 3591 for details. See PR 4714.
- Deprecate
libp2p::swarm::SwarmBuilder
. Most users should uselibp2p::SwarmBuilder
. In some special cases, users may need to useSwarm::new
andConfig
instead of the newlibp2p::SwarmBuilder
. See PR 4120. - Make the
Debug
implementation ofStreamProtocol
more concise. See PR 4631. - Fix overflow in
KeepAlive
computation that could occur panic atDelay::new
ifSwarmBuilder::idle_connection_timeout
is configured too large. See PR 4644. - Deprecate
KeepAlive::Until
. Individual protocols should not keep connections alive for longer than necessary. Users should useswarm::Config::idle_connection_timeout
instead. See PR 4656. - Deprecate
keep_alive_timeout
inOneShotHandlerConfig
. See PR 4680.
- Fix overflow in
KeepAlive
computation that could occur ifSwarmBuilder::idle_connection_timeout
is configured withu64::MAX
. See PR 4559.
-
Implement
Debug
for event structs. See PR 4426. -
Improve error message when
DialPeerCondition
prevents a dial. See PR 4409. -
Introduce
SwarmBuilder::idle_conncetion_timeout
and deprecatekeep_alive::Behaviour
as a result. See PR 4161.
- Implement
Display
forConnectionId
. See PR 4278.
- Display the cause of a
ListenError::Denied
. See PR 4232
- Do not announce external address candidate before address translation, unless translation does not apply. This will prevent ephemeral TCP addresses being announced as external address candidates. See PR 4158.
-
Allow
NetworkBehaviours
to create and remove listeners. See PR 3292. -
Raise MSRV to 1.65. See PR 3715.
-
Introduce
StreamProtocol
type. This type enforces invariants on protocol names, such as leading forward slashes and correct UTF8 encoding. See PR 3746. -
Return a bool from
ExternalAddresses::on_swarm_event
andListenAddresses::on_swarm_event
indicating whether any state was changed. See PR 3865. -
Remove deprecated banning API from
Swarm
. Users should migrate tolibp2p::allow_block_list
. See PR 3886. -
Remove
ConnectionHandlerUpgrErr::Timer
variant. This variant was never constructed and thus dead code. See PR 3605. -
Remove deprecated
IntoConnectionHandler
and all its implementations. This also removes theNetworkBehaviour::new_handler
andNetworkBehaviour::addresses_of_peer
methods. See changelog for0.42
on how to migrate. See PR 3884. -
Remove
ConnectionHandlerUpgrErr::Timer
variant. This variant was never constructed and thus dead code. See PR 3605. -
Flatten
ConnectionHandlerUpgrErr
and rename toStreamUpgradeError
. See PR 3882. -
Remove deprecated
ConnectionLimits
. Users should migrate tolibp2p::connection_limits::Behaviour
. See PR 3885. -
Allow
ConnectionHandler
s to report and learn about the supported protocols on a connection. The newly introduced API elements are:ConnectionHandlerEvent::ReportRemoteProtocols
ConnectionEvent::LocalProtocolsChange
ConnectionEvent::RemoteProtocolsChange
See PR 3651.
-
Deprecate the
NegotiatedSubstream
type and replace it withStream
. See PR 3912. -
Rename
NetworkBehaviour::OutEvent
toNetworkBehaviour::ToSwarm
,ConnectionHandler::InEvent
toConnectionHandler::FromBehaviour
,ConnectionHandler::OutEvent
toConnectionHandler::ToBehaviour
. See PR 3848. -
Remove deprecated
NetworkBehaviourAction
type. See PR 3919. -
Expose
ConnectionId
onSwarmEvent::{ConnectionEstablished,ConnectionClosed,IncomingConnection,IncomingConnectionError,OutgoingConnectionError,Dialing}
. Also emitSwarmEvent::Dialing
for dials with unknownPeerId
. See PR 3927. -
Rename
ConnectionHandlerEvent::Custom
toConnectionHandlerEvent::NotifyBehaviour
. See PR 3955. -
Remove
DialError::InvalidPeerId
variant. With the move tomultiaddr
v0.18.0
peer IDs in/p2p
are type safe and thus usage of the contained peer ID can not result in a parsing error. See PR 4037. -
Remove deprecated items. See PR 3956.
-
Add ability to
downcast_ref
ConnectionDenied errors. See PR 4020.
- Add
ConnectionEvent::{is_outbound,is_inbound}
. See PR 3625.
-
Deprecate
ConnectionLimits
in favor oflibp2p::connection_limits
. See PR 3386. -
Introduce
ConnectionId::new_unchecked
to allow for more sophisticated, manual tests ofNetworkBehaviour
. See PR 3652. -
Deprecate
Swarm::ban_peer_id
in favor of the newlibp2p::allow_block_list
module. See PR 3590. -
Rename
NetworkBehaviourAction
toToSwarm
. A deprecated type-alias is provided to ease the transition. The new name is meant to better indicate the message-passing relationship betweenSwarm
andNetworkBehaviour
. See PR 3658.
-
Allow
NetworkBehaviour
s to manage connections. We deprecateNetworkBehaviour::new_handler
andNetworkBehaviour::addresses_of_peer
in favor of four new callbacks:NetworkBehaviour::handle_pending_inbound_connection
NetworkBehaviour::handle_pending_outbound_connection
NetworkBehaviour::handle_established_inbound_connection
NetworkBehaviour::handle_established_outbound_connection
Please note that due to limitations in the Rust compiler, implementations of
new_handler
andaddresses_of_peer
are not flagged as deprecated. Nevertheless, they will be removed in the future.All four are fallible and returning an error from any of them will abort the given connection. This allows you to create dedicated
NetworkBehaviour
s that only concern themselves with managing connections. For example:- checking the
PeerId
of a newly established connection against an allow/block list - only allowing X connection upgrades at any one time
- denying incoming or outgoing connections from a certain IP range
- only allowing N connections to or from the same peer
See PR 3254.
-
Remove
handler
field fromNetworkBehaviourAction::Dial
. Instead of constructing the handler early, you can now access theConnectionId
of the future connection onDialOpts
.ConnectionId
s areCopy
and will be used throughout the entire lifetime of the connection to report events. This allows you to send events to a very specific connection, much like you previously could directly set state in the handler.Removing the
handler
field also reduces the type parameters ofNetworkBehaviourAction
from three to two. The third one used to be defaulted to theInEvent
of theConnectionHandler
. You now have to manually specify that where you previously had to specify theConnectionHandler
. This very likely will trigger convoluted compile errors about traits not being implemented.Within
NetworkBehaviourAction::poll
, the easiest way to migrate is to do this (in the example oflibp2p-floodsub
):--- a/protocols/floodsub/src/layer.rs +++ b/protocols/floodsub/src/layer.rs @@ -472,7 +465,7 @@ impl NetworkBehaviour for Floodsub { &mut self, _: &mut Context<'_>, _: &mut impl PollParameters, - ) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>> { + ) -> Poll<NetworkBehaviourAction<Self::OutEvent, THandlerInEvent<Self>>> {
In other words:
Search Replace NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>
NetworkBehaviourAction<Self::OutEvent, THandlerInEvent<Self>>
If you reference
NetworkBehaviourAction
somewhere else as well, you may have to fill in the type ofConnectionHandler::InEvent
manually as the 2nd parameter.See PR 3328.
-
Update to
libp2p-core
v0.39.0
. -
Removed deprecated Swarm constructors. For transition notes see 0.41.0. See PR 3170.
-
Deprecate functions on
PollParameters
in preparation forPollParameters
to be removed entirely eventually. See PR 3153. -
Add
estblished_in
toSwarmEvent::ConnectionEstablished
. See PR 3134. -
Remove deprecated
inject_*
methods fromNetworkBehaviour
andConnectionHandler
. Make the implementation ofon_swarm_event
andon_connection_handler_event
both mandatory. See PR 3264 and PR 3364. -
Update to
libp2p-swarm-derive
v0.32.0
. -
Replace
SwarmBuilder::connection_event_buffer_size
withSwarmBuilder::per_connection_event_buffer_size
. The configured value now applies per connection. The default values remains 7. If you have previously setconnection_event_buffer_size
you should re-evaluate what a good size for a per connection buffer is. See PR 3188. -
Remove
DialError::ConnectionIo
variant. This was never constructed. See PR 3374. -
Introduce
ListenError
and use it withinSwarmEvent::IncomingConnectionError
. See PR 3375. -
Remove
PendingConnectionError
,PendingInboundConnectionError
andPendingOutboundConnectionError
from the public API. They are no longer referenced anywhere with the addition ofListenError
. See PR 3497. -
Remove
ConnectionId::new
. Manually creatingConnectionId
s is now unsupported. See PR 3327. -
Deprecate methods
Swarm::with_executor
,Swarm::with_*_executor
,Swarm::without_executor
. Introduce similar methods inSwarmBuilder
. See PR 3588. -
Gracefully disable oneshot handler on dial upgrade errors. See PR 3577.
- Update to
libp2p-swarm-derive
v0.31.0
.
-
Update to
libp2p-core
v0.38.0
. -
Add new
on_connection_event
method toConnectionHandler
that accepts aConnectionEvent
enum and updateinject_*
methods to callon_connection_event
with the respectiveConnectionEvent
variant and deprecateinject_*
. To migrate, users should replace theConnectionHandler::inject_*
calls with a single implementation ofConnectionHandler::on_connection_event
treating eachConnectionEvent
variant in the same way its correspondinginject_*
call was treated. See PR 3085. -
Add new
on_behaviour_event
method with the same signature asinject_event
, make the default implementation ofinject_event
callon_behaviour_event
and deprecate it. To migrate, users should replace theConnectionHandler::inject_event
call withConnectionHandler::on_behaviour_event
. See PR 3085. -
Add new
on_swarm_event
method toNetworkBehaviour
that accepts aFromSwarm
enum and updateinject_*
methods to callon_swarm_event
with the respectiveFromSwarm
variant and deprecateinject_*
. To migrate, users should replace theNetworkBehaviour::inject_*
calls with a single implementation ofNetworkBehaviour::on_swarm_event
treating eachFromSwarm
variant in the same way its correspondinginject_*
call was treated. See PR 3011. -
Add new
on_connection_handler_event
method with the same signature asinject_event
, make the default implementation ofinject_event
callon_connection_handler_event
and deprecate it. To migrate, users should replace theNetworkBehaviour::inject_event
call withNetworkBehaviour::on_connection_handler_event
. See PR 3011. -
Export
NetworkBehaviour
derive aslibp2p_swarm::NetworkBehaviour
. This follows the convention of other popular libraries.serde
for example exports theSerialize
trait and macro asserde::Serialize
. See PR 3055. -
Feature-gate
NetworkBehaviour
macro behindmacros
feature flag. See PR 3055. -
Make executor in Swarm constructor explicit. See PR 3097.
Supported executors:
-
Tokio
Previously
let swarm = SwarmBuilder::new(transport, behaviour, peer_id) .executor(Box::new(|fut| { tokio::spawn(fut); })) .build();
Now
let swarm = Swarm::with_tokio_executor(transport, behaviour, peer_id);
-
Async Std
Previously
let swarm = SwarmBuilder::new(transport, behaviour, peer_id) .executor(Box::new(|fut| { async_std::task::spawn(fut); })) .build();
Now
let swarm = Swarm::with_async_std_executor(transport, behaviour, peer_id);
-
ThreadPool (see Issue 3107)
In most cases ThreadPool can be replaced by executors or spawning on the local task.
Previously
let swarm = Swarm::new(transport, behaviour, peer_id);
Now
let swarm = Swarm::with_threadpool_executor(transport, behaviour, peer_id);
-
Without
Spawns the tasks on the current task, this may result in bad performance so try to use an executor where possible. Previously this was just a fallback when no executor was specified and constructing a
ThreadPool
failed.New
let swarm = Swarm::without_executor(transport, behaviour, peer_id);
Deprecated APIs:
Swarm::new
SwarmBuilder::new
SwarmBuilder::executor
-
-
Update
rust-version
to reflect the actual MSRV: 1.62.0. See PR 3090.
-
Bump rand to 0.8 and quickcheck to 1. See PR 2857.
-
Update to
libp2p-core
v0.37.0
. -
Introduce
libp2p_swarm::keep_alive::ConnectionHandler
in favor of removingkeep_alive
fromlibp2p_swarm::dummy::ConnectionHandler
.dummy::ConnectionHandler
now literally does not do anything. In the same spirit, introducelibp2p_swarm::keep_alive::Behaviour
andlibp2p_swarm::dummy::Behaviour
. See PR 2859.
- Pass actual
PeerId
of dial toNetworkBehaviour::inject_dial_failure
onDialError::ConnectionLimit
. See PR 2928.
-
Remove deprecated
NetworkBehaviourEventProcess
. See libp2p-swarm v0.38.0 changelog entry for migration path. -
Update to
libp2p-core
v0.36.0
. -
Enforce backpressure on incoming streams via
StreamMuxer
interface. In case we hit the configured limit of maximum number of inbound streams, we will stop polling theStreamMuxer
for new inbound streams. Depending on the muxer implementation in use, this may lead to instant dropping of inbound streams. See PR 2861.
-
Deprecate
NetworkBehaviourEventProcess
. When derivingNetworkBehaviour
on a customstruct
users should either bring their ownOutEvent
via#[behaviour(out_event = "MyBehaviourEvent")]
or, when not specified, have the derive macro generate one for the user.See
NetworkBehaviour
documentation and PR 2784 for details.Previously
#[derive(NetworkBehaviour)] #[behaviour(event_process = true)] struct MyBehaviour { gossipsub: Gossipsub, mdns: Mdns, } impl NetworkBehaviourEventProcess<Gossipsub> for MyBehaviour { fn inject_event(&mut self, message: GossipsubEvent) { todo!("Handle event") } } impl NetworkBehaviourEventProcess<MdnsEvent> for MyBehaviour { fn inject_event(&mut self, message: MdnsEvent) { todo!("Handle event") } }
Now
#[derive(NetworkBehaviour)] #[behaviour(out_event = "MyBehaviourEvent")] struct MyBehaviour { gossipsub: Gossipsub, mdns: Mdns, } enum MyBehaviourEvent { Gossipsub(GossipsubEvent), Mdns(MdnsEvent), } impl From<GossipsubEvent> for MyBehaviourEvent { fn from(event: GossipsubEvent) -> Self { MyBehaviourEvent::Gossipsub(event) } } impl From<MdnsEvent> for MyBehaviourEvent { fn from(event: MdnsEvent) -> Self { MyBehaviourEvent::Mdns(event) } } match swarm.next().await.unwrap() { SwarmEvent::Behaviour(MyBehaviourEvent::Gossipsub(event)) => { todo!("Handle event") } SwarmEvent::Behaviour(MyBehaviourEvent::Mdns(event)) => { todo!("Handle event") } }
-
When deriving
NetworkBehaviour
on a customstruct
where the user does not specify their ownOutEvent
via#[behaviour(out_event = "MyBehaviourEvent")]
and where the user does not enable#[behaviour(event_process = true)]
, then the derive macro generates anOutEvent
definition for the user.See
NetworkBehaviour
documentation and PR 2792 for details. -
Update dial address concurrency factor to
8
, thus dialing up to 8 addresses concurrently for a single connection attempt. SeeSwarm::dial_concurrency_factor
and PR 2741. -
Update to
libp2p-core
v0.35.0
.
-
Update to
libp2p-core
v0.34.0
. -
Extend log message when exceeding inbound negotiating streams with peer ID and limit. See PR 2716.
-
Remove
connection::ListenersStream
and poll theTransport
directly. See PR 2652.
- Limit negotiating inbound substreams per connection. See PR 2697.
-
Don't require
Transport
to beClone
. See PR 2529. -
Update to
libp2p-core
v0.33.0
. -
Make
behaviour::either
module private. See PR 2610 -
Rename
IncomingInfo::to_connected_point
toIncomingInfo::create_connected_point
. See PR 2620. -
Rename
TProtoHandler
toTConnectionHandler
,ToggleProtoHandler
toToggleConnectionHandler
,ToggleIntoProtoHandler
toToggleIntoConnectionHandler
. See PR 2640.
- Add impl
IntoIterator
forMultiHandler
. See PR 2572. - Remove
Send
bound fromNetworkBehaviour
. See PR 2535.
-
Rename
ProtocolsHandler
toConnectionHandler
. Upgrade should be as simple as renaming all occurrences ofProtocolsHandler
toConnectionHandler
with your favorite text manipulation tool across your codebase. See PR 2527. -
Fold
libp2p-core
'sNetwork
intoSwarm
. See PR 2492. -
Update to
libp2p-core
v0.32.0
. -
Disconnect pending connections with
Swarm::disconnect
. See PR 2517. -
Report aborted connections via
SwarmEvent::OutgoingConnectionError
. See PR 2517.
-
Patch reporting on banned peers and their non-banned and banned connections (see PR 2350).
-
Update dependencies.
-
Migrate to Rust edition 2021 (see PR 2339).
-
Update
Connection::address
oninject_address_change
(see PR 2362). -
Move
swarm::Toggle
toswarm::behaviour::Toggle
(see PR 2375). -
Add
Swarm::connected_peers
(see PR 2378). -
Implement
swarm::NetworkBehaviour
oneither::Either
(see PR 2370). -
Allow overriding dial concurrency factor per dial via
DialOpts::override_dial_concurrency_factor
. See PR 2404. -
Report negotiated and expected
PeerId
as well as remote address inDialError::WrongPeerId
(see PR 2428). -
Allow overriding role when dialing through
override_role
option onDialOpts
. This option is needed for NAT and firewall hole punching. See PR 2363. -
Merge NetworkBehaviour's inject_* paired methods (see PR 2445).
-
Use
instant
andfutures-timer
instead ofwasm-timer
(see PR 2245). -
Enable advanced dialing requests both on
Swarm::dial
and viaNetworkBehaviourAction::Dial
. Users can now trigger a dial with a specific set of addresses, optionally extended viaNetworkBehaviour::addresses_of_peer
.Changes required to maintain status quo:
-
Previously
swarm.dial(peer_id)
nowswarm.dial(DialOpts::peer_id(peer_id).build())
orswarm.dial(peer_id)
given thatDialOpts
implementsFrom<PeerId>
. -
Previously
swarm.dial_addr(addr)
nowswarm.dial(DialOpts::unknown_peer_id().address(addr).build())
orswarm.dial(addr)
given thatDialOpts
implementsFrom<Multiaddr>
. -
Previously
NetworkBehaviourAction::DialPeer { peer_id, condition, handler }
nowNetworkBehaviourAction::Dial { opts: DialOpts::peer_id(peer_id) .condition(condition) .build(), handler, }
-
Previously
NetworkBehaviourAction::DialAddress { address, handler }
nowNetworkBehaviourAction::Dial { opts: DialOpts::unknown_peer_id() .address(address) .build(), handler, }
See PR 2317.
-
-
Make default features of
libp2p-core
optional. PR 2181 -
Update dependencies.
-
Provide default implementations for all functions of
NetworkBehaviour
, except fornew_handler
,inject_event
andpoll
. This should make it easier to create new implementations. See PR 2150. -
Remove
Swarm
type alias and renameExpandedSwarm
toSwarm
. Reduce direct trait parameters onSwarm
(previouslyExpandedSwarm
), deriving parameters through associated types onTBehaviour
. See PR 2182. -
Require
ProtocolsHandler::{InEvent,OutEvent,Error}
to implementDebug
(see PR 2183). -
Implement
ProtocolsHandler
oneither::Either
representing either of twoProtocolsHandler
implementations (see PR 2192). -
Require implementation to provide handler in
NetworkBehaviourAction::DialPeer
andNetworkBehaviourAction::DialAddress
. Note that the handler is returned to theNetworkBehaviour
on connection failure and connection closing. Thus it can be used to carry state, which otherwise would have to be tracked in theNetworkBehaviour
itself. E.g. a message destined to an unconnected peer can be included in the handler, and thus directly send on connection success or extracted by theNetworkBehaviour
on connection failure (see PR 2191). -
Include handler in
NetworkBehaviour::inject_dial_failure
,NetworkBehaviour::inject_connection_closed
,NetworkBehaviour::inject_listen_failure
(see PR 2191). -
Include error in
NetworkBehaviour::inject_dial_failure
and callNetworkBehaviour::inject_dial_failure
onDialPeerCondition
evaluating to false. To emulate the previous behaviour, return early withininject_dial_failure
onDialError::DialPeerConditionFalse
. See PR 2191. -
Make
NetworkBehaviourAction
generic overNetworkBehaviour::OutEvent
andNetworkBehaviour::ProtocolsHandler
. In most cases, change your generic type parameters toNetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>
. See PR 2191. -
Return
bool
instead ofResult<(), ()>
forSwarm::remove_listener
(see PR 2261). -
Concurrently dial address candidates within a single dial attempt (see PR 2248) configured via
Swarm::dial_concurrency_factor
.-
On success of a single address, report errors of the thus far failed dials via
SwarmEvent::ConnectionEstablished::outgoing
. -
On failure of all addresses, report errors via the new
SwarmEvent::OutgoingConnectionError
. -
Remove
SwarmEvent::UnreachableAddr
andSwarmEvent::UnknownPeerUnreachableAddr
event. -
In
NetworkBehaviour::inject_connection_established
provide errors of all thus far failed addresses. -
On unknown peer dial failures, call
NetworkBehaviour::inject_dial_failure
with a peer ID ofNone
. -
Remove
NetworkBehaviour::inject_addr_reach_failure
. Information is now provided viaNetworkBehaviour::inject_connection_established
andNetworkBehaviour::inject_dial_failure
.
-
-
Update dependencies.
-
Drive
ExpandedSwarm
viaStream
trait only.-
Change
Stream
implementation ofExpandedSwarm
to return allSwarmEvents
instead of only theNetworkBehaviour
's events. -
Remove
ExpandedSwarm::next_event
. Users can use<ExpandedSwarm as StreamExt>::next
instead. -
Remove
ExpandedSwarm::next
. Users can use<ExpandedSwarm as StreamExt>::filter_map
instead.
See PR 2100 for details.
-
-
Add
ExpandedSwarm::disconnect_peer_id
andNetworkBehaviourAction::CloseConnection
to close connections to a specific peer via anExpandedSwarm
orNetworkBehaviour
. See PR 2110 for details. -
Expose the
ListenerId
inSwarmEvent
s that are associated with a listener.See PR 2123 for details.
-
Remove
Deref
andDerefMut
implementations previously dereferencing to theNetworkBehaviour
onSwarm
. Instead one can access theNetworkBehaviour
viaSwarm::behaviour
andSwarm::behaviour_mut
. Methods onSwarm
can now be accessed directly, e.g. viamy_swarm.local_peer_id()
. You may use the command below to transform fully qualified method calls onSwarm
to simple method calls PR 1995.# Go from e.g. `Swarm::local_peer_id(&my_swarm)` to `my_swarm.local_peer_id()`. grep -RiIl --include \*.rs --exclude-dir target . --exclude-dir .git | xargs sed -i "s/\(libp2p::\)*Swarm::\([a-z_]*\)(&mut \([a-z_0-9]*\), /\3.\2(/g"
-
Extend
NetworkBehaviour
callbacks, more concretely introducing newfn inject_new_listener
andfn inject_expired_external_addr
and havefn inject_{new,expired}_listen_addr
provide aListenerId
PR 2011.
-
New error variant
DialError::InvalidAddress
-
Swarm::dial_addr()
now returns aDialError
on error. -
Remove the option for a substream-specific multistream select protocol override. The override at this granularity is no longer deemed useful, in particular because it can usually not be configured for existing protocols like
libp2p-kad
and others. There is aSwarm
-scoped configuration for this version available since 1858.
- Have
ToggleProtoHandler
ignore listen upgrade errors when disabled. PR 1945.
-
Make
OneShotHandler
smax_dial_negotiate
limit configurable. PR 1936. -
Fix handling of DialPeerCondition::Always. PR 1937.
- Update dependencies.
-
Update
libp2p-core
. -
Remove
NotifyHandler::All
thus removing the requirement for events send from aNetworkBehaviour
to aProtocolsHandler
to beClone
. PR 1880.
- Add
ExpandedSwarm::is_connected
. PR 1862.
-
Permit a configuration override for the substream upgrade protocol to use for all (outbound) substreams. PR 1858.
-
Changed parameters for connection limits from
usize
tou32
. Connection limits are now configured viaSwarmBuilder::connection_limits()
. -
Update
libp2p-core
. -
Expose configurable scores for external addresses, as well as the ability to remove them and to add addresses that are retained "forever" (or until explicitly removed). PR 1842.
- Update dependencies.
-
Require a
Boxed
transport to be given to theSwarm
orSwarmBuilder
to avoid unnecessary double-boxing of transports and simplify API bounds. PR 1794 -
Respect inbound timeouts and upgrade versions in the
MultiHandler
. PR 1786. -
Instead of iterating each inbound and outbound substream upgrade looking for one to make progress, use a
FuturesUnordered
for both pending inbound and pending outbound upgrades. As a result only those upgrades are polled that are ready to progress.Implementors of
InboundUpgrade
andOutboundUpgrade
need to ensure to wake up the underlying task once they are ready to make progress as they won't be polled otherwise.
-
Bump
libp2p-core
dependency. -
Adds
ProtocolsHandler::InboundOpenInfo
type which mirrors the existingOutboundOpenInfo
type. A value of this type is passed as an extra argument toProtocolsHandler::inject_fully_negotiated_inbound
andProtocolsHandler::inject_listen_upgrade_error
. -
SubstreamProtocol
now has a second type parameter corresponding to inbound or outbound information, a value of which is part ofSubstreamProtocol
now. ConsequentlyProtocolsHandlerEvent::OutboundSubstreamRequest
no longer has a separateinfo
field.
-
Add missing delegation calls in some
ProtocolsHandler
wrappers. See PR 1710. -
Add as_ref and as_mut functions to Toggle PR 1684.
-
The
cause
ofSwarmEvent::ConnectionClosed
is now anOption
, andNone
indicates an active connection close not caused by an error. -
DialError::Banned
has been added and is returned fromSwarm::dial
if the peer is banned, thereby also invoking theNetworkBehaviour::inject_dial_failure
callback. -
Update the
libp2p-core
dependency to0.21
, fixing 1584. -
Fix connections being kept alive by
OneShotHandler
when not handling any requests PR 1698.
-
Documentation updates.
-
Ignore addresses returned by
NetworkBehaviour::addresses_of_peer
that theSwarm
considers to be listening addresses of the local node. This avoids futile dialing attempts of a node to itself, which can otherwise even happen in genuine situations, e.g. after the local node changed its network identity and a behaviour makes a dialing attempt to a former identity using the same addresses.
-
Updated the
libp2p-core
dependency. -
Add
ProtocolsHandler::inject_listen_upgrade_error
, the inbound analogue ofProtocolsHandler::inject_dial_upgrade_error
, with an empty default implementation. No implementation is required to retain existing behaviour. -
Add
ProtocolsHandler::inject_address_change
andNetworkBehaviour::inject_address_change
to notify of a change in the address of an existing connection.
- Bugfix: Fix MultiHandler panicking when empty (PR 1598).