diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index 8eda0e46..2deb016f 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -384,8 +384,7 @@ func (h *BasicHost) Connect(ctx context.Context, pi pstore.PeerInfo) error { // absorb addresses into peerstore h.Peerstore().AddAddrs(pi.ID, pi.Addrs, pstore.TempAddrTTL) - cs := h.Network().ConnsToPeer(pi.ID) - if len(cs) > 0 { + if h.Network().Connectedness(pi.ID) == inet.Connected { return nil } diff --git a/p2p/host/routed/routed.go b/p2p/host/routed/routed.go index df837fc7..99926f2b 100644 --- a/p2p/host/routed/routed.go +++ b/p2p/host/routed/routed.go @@ -47,7 +47,7 @@ func Wrap(h host.Host, r Routing) *RoutedHost { // given peer, it will use its routing system to try to find some. func (rh *RoutedHost) Connect(ctx context.Context, pi pstore.PeerInfo) error { // first, check if we're already connected. - if len(rh.Network().ConnsToPeer(pi.ID)) > 0 { + if rh.Network().Connectedness(pi.ID) == inet.Connected { return nil }