-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
swarm/: Enable dialing a specific fixed set of addresses for a single peer #2249
Comments
We could express this with: enum NetworkBehaviourAction {
Dial {
peer_id: Option<PeerId>,
addresses: Option<Vec<Multiaddress>>
}
} With the following conventions:
This would flatten out the structure a bit and avoid having another enum that we need to import / use. To make things easier to construct, we could have constructor functions on Having written that though, maybe the best combination would be constructor functions + a dedicated enum internally to remove the "Invalid combination" case. |
I am leaning towards making invalid combinations invalid at compile time, e.g. through a dedicated enum. I still need to give this more thoughts and experiment. |
Status Quo
One can either
(a) request a dial of a specific peer by their
PeerId
viaNetworkBehaviourAction::DialPeer
, where the concrete addresses to be dialed are collected viaNetworkBehaviour::addresses_of_peer
or (b) request a dial of a single specific address via
NetworkBehaviourAction::DialAddress
Problem
A
NetworkBehaviour
implementation might want to choose the specific fixed set of addresses to be dialed for a given peer. This is the case in #2076 where the remote provides a specific set of addresses to be dialed by the local node.Using
NetworkBehaviourAction::DialPeer
and providing the set of addresses viaNetworkBehaviour::addresses_of_peer
does not prevent otherNetworkBehaviour
implementations to add bogus addresses to the set viaNetworkBehaviour::addresses_of_peer
.Proposal
NetworkBehaviourAction::DialPeer
andNetworkBehaviourAction::DialAddress
into a singleNetworkBehaviourAction::Dial
.NetworkBehaviourAction::Dial
allow specifying either:PeerId
only, where theSwarm
retrieves corresponding addresses viaNetworkBehaviour::addresses_of_peer
.PeerId
and a set of addressesSwarm
extending the set of addresses viaNetworkBehaviour::addresses_of_peer
.Miscellaneous
Next to enabling a
NetworkBehaviour
implementation to specify a specific fixed set of addresses to be dialed, the change above would simplify other implementations. E.g. in the case where aNetworkBehaviour
implementation wants to dial a peer by itsPeerId
, also providing some addresses, it can provide these addresses right away withinNetworkBehaviourAction::Dial
, instead of first emitting aNetworkBehaviourAction::DialPeer
and then providing the set of addresses viaNetworkBehaviour::addresses_of_peer
.To reduce conflicts I would suggest tackling this after core/: Concurrent connection attempts #2248 is merged.
The text was updated successfully, but these errors were encountered: