Skip to content

Commit ee01db8

Browse files
committed
fix: Unexport hasValidConnectedness to make a patch release
1 parent 1626e6b commit ee01db8

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

dht.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ func (dht *IpfsDHT) FindLocal(ctx context.Context, id peer.ID) peer.AddrInfo {
737737
_, span := internal.StartSpan(ctx, "IpfsDHT.FindLocal", trace.WithAttributes(attribute.Stringer("PeerID", id)))
738738
defer span.End()
739739

740-
if HasValidConnectedness(dht.host, id) {
740+
if hasValidConnectedness(dht.host, id) {
741741
return dht.peerstore.PeerInfo(id)
742742
}
743743
return peer.AddrInfo{}
@@ -926,7 +926,7 @@ func (dht *IpfsDHT) newContextWithLocalTags(ctx context.Context, extraTags ...ta
926926

927927
func (dht *IpfsDHT) maybeAddAddrs(p peer.ID, addrs []ma.Multiaddr, ttl time.Duration) {
928928
// Don't add addresses for self or our connected peers. We have better ones.
929-
if p == dht.self || HasValidConnectedness(dht.host, p) {
929+
if p == dht.self || hasValidConnectedness(dht.host, p) {
930930
return
931931
}
932932
dht.peerstore.AddAddrs(p, dht.filterAddrs(addrs), ttl)

dht_filters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func inAddrRange(ip net.IP, ipnets []*net.IPNet) bool {
239239
return false
240240
}
241241

242-
func HasValidConnectedness(host host.Host, id peer.ID) bool {
242+
func hasValidConnectedness(host host.Host, id peer.ID) bool {
243243
connectedness := host.Network().Connectedness(id)
244244
return connectedness == network.Connected || connectedness == network.Limited
245245
}

fullrt/dht.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ func (dht *FullRT) FindPeer(ctx context.Context, id peer.ID) (pi peer.AddrInfo,
14591459

14601460
// Return peer information if we tried to dial the peer during the query or we are (or recently were) connected
14611461
// to the peer.
1462-
if kaddht.HasValidConnectedness(dht.h, id) {
1462+
if hasValidConnectedness(dht.h, id) {
14631463
return dht.h.Peerstore().PeerInfo(id), nil
14641464
}
14651465

@@ -1537,16 +1537,21 @@ func (dht *FullRT) getRecordFromDatastore(ctx context.Context, dskey ds.Key) (*r
15371537

15381538
// FindLocal looks for a peer with a given ID connected to this dht and returns the peer and the table it was found in.
15391539
func (dht *FullRT) FindLocal(id peer.ID) peer.AddrInfo {
1540-
if kaddht.HasValidConnectedness(dht.h, id) {
1540+
if hasValidConnectedness(dht.h, id) {
15411541
return dht.h.Peerstore().PeerInfo(id)
15421542
}
15431543
return peer.AddrInfo{}
15441544
}
15451545

15461546
func (dht *FullRT) maybeAddAddrs(p peer.ID, addrs []multiaddr.Multiaddr, ttl time.Duration) {
15471547
// Don't add addresses for self or our connected peers. We have better ones.
1548-
if p == dht.h.ID() || kaddht.HasValidConnectedness(dht.h, p) {
1548+
if p == dht.h.ID() || hasValidConnectedness(dht.h, p) {
15491549
return
15501550
}
15511551
dht.h.Peerstore().AddAddrs(p, addrs, ttl)
15521552
}
1553+
1554+
func hasValidConnectedness(host host.Host, id peer.ID) bool {
1555+
connectedness := host.Network().Connectedness(id)
1556+
return connectedness == network.Connected || connectedness == network.Limited
1557+
}

routing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (pi peer.AddrInfo,
663663
return peers, err
664664
},
665665
func(*qpeerset.QueryPeerset) bool {
666-
return HasValidConnectedness(dht.host, id)
666+
return hasValidConnectedness(dht.host, id)
667667
},
668668
)
669669

@@ -684,7 +684,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (pi peer.AddrInfo,
684684

685685
// Return peer information if we tried to dial the peer during the query or we are (or recently were) connected
686686
// to the peer.
687-
if dialedPeerDuringQuery || HasValidConnectedness(dht.host, id) {
687+
if dialedPeerDuringQuery || hasValidConnectedness(dht.host, id) {
688688
return dht.peerstore.PeerInfo(id), nil
689689
}
690690

0 commit comments

Comments
 (0)