Skip to content

Commit c5fbf5a

Browse files
fix(libp2p): remove ping after handshake
1 parent 2f10842 commit c5fbf5a

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

pkg/p2p/libp2p/libp2p.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
388388
wssResolver = r
389389
}
390390

391-
// Add WebSocket transport(s) based on configuration
392391
if o.EnableWSS {
393392
wsOpt := ws.WithTLSConfig(certManager.TLSConfig())
394393
transports = append(transports, libp2p.Transport(ws.New, wsOpt))
@@ -404,19 +403,6 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
404403
if o.EnableWSS {
405404
certManagerAddressFactory := certManager.AddressFactory()
406405
addrs = certManagerAddressFactory(addrs)
407-
408-
// Sort to prioritize public addresses (only meaningful with WSS, but harmless otherwise)
409-
slices.SortStableFunc(addrs, func(a, b ma.Multiaddr) int {
410-
aPub := manet.IsPublicAddr(a)
411-
bPub := manet.IsPublicAddr(b)
412-
if aPub == bPub {
413-
return 0
414-
}
415-
if aPub {
416-
return -1
417-
}
418-
return 1
419-
})
420406
}
421407

422408
return addrs
@@ -1080,24 +1066,6 @@ func (s *Service) Connect(ctx context.Context, addrs []ma.Multiaddr) (address *b
10801066
return nil, fmt.Errorf("connect full close %w", err)
10811067
}
10821068

1083-
// TODO: do we need to ping here? the handshake already verifies liveness?
1084-
var pingErr error
1085-
for _, addr := range addrs {
1086-
pingCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
1087-
_, err := s.Ping(pingCtx, addr)
1088-
cancel() // Cancel immediately after use
1089-
if err == nil {
1090-
pingErr = nil
1091-
break
1092-
}
1093-
pingErr = err
1094-
}
1095-
1096-
if pingErr != nil {
1097-
_ = s.Disconnect(overlay, "peer disconnected immediately after handshake")
1098-
return nil, p2p.ErrPeerNotFound
1099-
}
1100-
11011069
if !s.peers.Exists(overlay) {
11021070
return nil, p2p.ErrPeerNotFound
11031071
}

0 commit comments

Comments
 (0)