Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions overlay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ stellar-xdr = { version = "=26.0.0", default-features = true }
libp2p = { version = "0.54", features = ["tokio", "macros", "identify", "quic"] }
libp2p-stream = "0.2.0-alpha"
futures = "0.3"
hickory-resolver = "0.24.4"

# Logging
tracing = "0.1"
Expand Down
8 changes: 7 additions & 1 deletion overlay/src/libp2p_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl StellarOverlay {
}
OverlayCommand::DialPeer { peer_id, addr } => {
let opts = DialOpts::peer_id(peer_id)
.condition(PeerCondition::Disconnected)
.condition(PeerCondition::DisconnectedAndNotDialing)
.addresses(vec![addr.clone()])
.build();
self.state.metrics.outbound_attempt.fetch_add(1, Ordering::Relaxed);
Expand Down Expand Up @@ -4628,6 +4628,7 @@ async fn test_dial_peer_skips_when_connected() {

// Record outbound_attempt before the PeerId-based dial
let attempts_before = m1.outbound_attempt.load(Ordering::Relaxed);
let pending_before = m1.connection_pending.load(Ordering::Relaxed);

// PeerId-based dial should be a no-op (already connected)
handle1.dial_peer(peer_id2, addr2.clone()).await;
Expand All @@ -4638,11 +4639,16 @@ async fn test_dial_peer_skips_when_connected() {
// outbound_attempt increments (we submitted the command), but connection_pending
// should NOT have changed (DialPeer was rejected by libp2p before handshake)
let attempts_after = m1.outbound_attempt.load(Ordering::Relaxed);
let pending_after = m1.connection_pending.load(Ordering::Relaxed);
assert_eq!(
attempts_after,
attempts_before + 1,
"outbound_attempt should increment by 1"
);
assert_eq!(
pending_after, pending_before,
"connection_pending should not change for an already-connected peer"
);

handle1.shutdown().await;
handle2.shutdown().await;
Expand Down
Loading
Loading