Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit concurrent dialing attempts per peer. #1506

Merged
merged 9 commits into from May 12, 2020

Conversation

romanb
Copy link
Contributor

@romanb romanb commented Mar 23, 2020

This is a follow-up to #1440 and relates to #925. This PR permits multiple dialing attempts per peer. The essence of the changes are that the Peer API in libp2p-core now provides Peer::dial(), i.e. regardless of the state in which the peer is. Previously dialing was only permitted on a ConnectedPeer or DisconnectedPeer. A dialing attempt is always made up of one or more addresses tried sequentially, as before, but now there can be multiple dialing attempts per peer. A configurable per-peer limit for outgoing connections and thus concurrent dialing attempts is also included. A NetworkBehaviour can now always request a new dialing attempt via DialPeerCondition::Always in NetworkBehaviourAction::DialPeer.

Another change included here is that Swarm::dial now returns Result<(), DialError> instead of Result<bool, ConnectionLimit>, i.e. the case of dialing failing because NetworkBehaviour::addresses_of_peer returning no addresses is now treated as an error (DialError::NoAddresses). This has the (I think) desirable effect of having a NetworkBehaviourAction::DialPeer request always be paired with a final call to inject_connection_established or inject_dial_failure. A behaviour may otherwise potentially keep state around for a dialing attempt that it thinks it emitted but for which it never got informed about a result.

This is a follow-up to libp2p#1440
and relates to libp2p#925.
This change permits multiple dialing attempts per peer.
Note though that `libp2p-swarm` does not yet make use of this ability,
retaining the current behaviour. The essence of the changes are that the
`Peer` API now provides `Peer::dial()`, i.e. regardless of the state in
which the peer is. A dialing attempt is always made up of one or more
addresses tried sequentially, as before, but now there can be multiple
dialing attempts per peer. A configurable per-peer limit for outgoing
connections and thus concurrent dialing attempts is also included.
For a cleaner API and to treat the case of no addresses
for a peer as an error, such that a `NetworkBehaviourAction::DialPeer`
request is always matched up with either `inject_connection_established`
or `inject_dial_error`.
Copy link
Contributor

@twittner twittner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but conflicts need to be resolved.

@romanb
Copy link
Contributor Author

romanb commented May 5, 2020

I integrated the latest changes from master.

@romanb romanb requested review from twittner and tomaka May 5, 2020 08:11
@romanb
Copy link
Contributor Author

romanb commented May 7, 2020

Thanks for the review. I still need to update the changelog, but otherwise if there are no further objections / comments by next Monday, I plan to merge this then.

@romanb romanb merged commit 5ba7c48 into libp2p:master May 12, 2020
@romanb romanb deleted the multicon-multidial branch May 12, 2020 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants