mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-27 16:51:34 +00:00
core/: Concurrent dial attempts (#2248)
Concurrently dial address candidates within a single dial attempt. Main motivation for this feature is to increase success rate on hole punching (see https://github.com/libp2p/rust-libp2p/issues/1896#issuecomment-885894496 for details). Though, as a nice side effect, as one would expect, it does improve connection establishment time. Cleanups and fixes done along the way: - Merge `pool.rs` and `manager.rs`. - Instead of manually implementing state machines in `task.rs` use `async/await`. - Fix bug where `NetworkBehaviour::inject_connection_closed` is called without a previous `NetworkBehaviour::inject_connection_established` (see https://github.com/libp2p/rust-libp2p/issues/2242). - Return handler to behaviour on incoming connection limit error. Missed in https://github.com/libp2p/rust-libp2p/issues/2242.
This commit is contained in:
@ -2927,6 +2927,7 @@ where
|
||||
peer_id: &PeerId,
|
||||
connection_id: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
_: Option<&Vec<Multiaddr>>,
|
||||
) {
|
||||
// Check if the peer is an outbound peer
|
||||
if let ConnectedPoint::Dialer { .. } = endpoint {
|
||||
|
@ -195,6 +195,7 @@ mod tests {
|
||||
send_back_addr: address,
|
||||
}
|
||||
},
|
||||
None,
|
||||
);
|
||||
<Gossipsub<D, F> as NetworkBehaviour>::inject_connected(gs, &peer);
|
||||
if let Some(kind) = kind {
|
||||
@ -533,6 +534,7 @@ mod tests {
|
||||
&ConnectedPoint::Dialer {
|
||||
address: "/ip4/127.0.0.1".parse::<Multiaddr>().unwrap(),
|
||||
},
|
||||
None,
|
||||
);
|
||||
gs.inject_connected(&random_peer);
|
||||
|
||||
@ -4085,6 +4087,7 @@ mod tests {
|
||||
&ConnectedPoint::Dialer {
|
||||
address: addr.clone(),
|
||||
},
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
@ -4103,6 +4106,7 @@ mod tests {
|
||||
&ConnectedPoint::Dialer {
|
||||
address: addr2.clone(),
|
||||
},
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
@ -4130,6 +4134,7 @@ mod tests {
|
||||
&ConnectedPoint::Dialer {
|
||||
address: addr.clone(),
|
||||
},
|
||||
None,
|
||||
);
|
||||
|
||||
//nothing changed
|
||||
|
Reference in New Issue
Block a user