Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: libp2p/go-libp2p-kad-dht
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.26.0
Choose a base ref
...
head repository: libp2p/go-libp2p-kad-dht
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.26.1
Choose a head ref
  • 11 commits
  • 6 files changed
  • 5 contributors

Commits on Aug 8, 2024

  1. updated TestRTEvictionOnFailedQuery

    guillaumemichel committed Aug 8, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4667e81 View commit details

Commits on Aug 14, 2024

  1. fix: treat limited connections as also connectable

    2color committed Aug 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    53fb5ad View commit details
  2. fix: check connectedness in separate function

    2color committed Aug 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    be9a8e7 View commit details

Commits on Aug 19, 2024

  1. fix: use a non-limited connection for querying

    2color committed Aug 19, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7004c77 View commit details

Commits on Aug 20, 2024

  1. Merge pull request #976 from libp2p/update-libp2p-more-fixes

    chore: fix connectedness
    MarcoPolo authored Aug 20, 2024
    Copy the full SHA
    96c96e3 View commit details

Commits on Aug 21, 2024

  1. Merge branch 'master' into steb/update-libp2p

    lidel authored Aug 21, 2024
    Copy the full SHA
    eb17ba7 View commit details
  2. Merge pull request #980 from libp2p/steb/update-libp2p

    correctly merging fix from  #976
    lidel authored Aug 21, 2024
    Copy the full SHA
    1626e6b View commit details
  3. fix: Unexport hasValidConnectedness to make a patch release

    MarcoPolo committed Aug 21, 2024
    Copy the full SHA
    ee01db8 View commit details
  4. Merge pull request #982 from libp2p/marco/unexport-hasValidConnectedness

    fix: Unexport hasValidConnectedness to make a patch release
    MarcoPolo authored Aug 21, 2024
    Copy the full SHA
    08676fa View commit details
  5. Release v0.26.1

    MarcoPolo committed Aug 21, 2024
    Copy the full SHA
    2044980 View commit details
  6. Merge pull request #983 from libp2p/marco/release-v0261

    Release v0.26.1
    MarcoPolo authored Aug 21, 2024
    Copy the full SHA
    9b16e14 View commit details
Showing with 22 additions and 15 deletions.
  1. +2 −2 dht.go
  2. +5 −0 dht_filters.go
  3. +8 −4 fullrt/dht.go
  4. +4 −4 query_test.go
  5. +2 −4 routing.go
  6. +1 −1 version.json
4 changes: 2 additions & 2 deletions dht.go
Original file line number Diff line number Diff line change
@@ -737,7 +737,7 @@ func (dht *IpfsDHT) FindLocal(ctx context.Context, id peer.ID) peer.AddrInfo {
_, span := internal.StartSpan(ctx, "IpfsDHT.FindLocal", trace.WithAttributes(attribute.Stringer("PeerID", id)))
defer span.End()

if dht.host.Network().Connectedness(id) == network.Connected {
if hasValidConnectedness(dht.host, id) {
return dht.peerstore.PeerInfo(id)
}
return peer.AddrInfo{}
@@ -926,7 +926,7 @@ func (dht *IpfsDHT) newContextWithLocalTags(ctx context.Context, extraTags ...ta

func (dht *IpfsDHT) maybeAddAddrs(p peer.ID, addrs []ma.Multiaddr, ttl time.Duration) {
// Don't add addresses for self or our connected peers. We have better ones.
if p == dht.self || dht.host.Network().Connectedness(p) == network.Connected {
if p == dht.self || hasValidConnectedness(dht.host, p) {
return
}
dht.peerstore.AddAddrs(p, dht.filterAddrs(addrs), ttl)
5 changes: 5 additions & 0 deletions dht_filters.go
Original file line number Diff line number Diff line change
@@ -238,3 +238,8 @@ func inAddrRange(ip net.IP, ipnets []*net.IPNet) bool {

return false
}

func hasValidConnectedness(host host.Host, id peer.ID) bool {
connectedness := host.Network().Connectedness(id)
return connectedness == network.Connected || connectedness == network.Limited
}
12 changes: 8 additions & 4 deletions fullrt/dht.go
Original file line number Diff line number Diff line change
@@ -1459,8 +1459,7 @@ func (dht *FullRT) FindPeer(ctx context.Context, id peer.ID) (pi peer.AddrInfo,

// Return peer information if we tried to dial the peer during the query or we are (or recently were) connected
// to the peer.
connectedness := dht.h.Network().Connectedness(id)
if connectedness == network.Connected {
if hasValidConnectedness(dht.h, id) {
return dht.h.Peerstore().PeerInfo(id), nil
}

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

// FindLocal looks for a peer with a given ID connected to this dht and returns the peer and the table it was found in.
func (dht *FullRT) FindLocal(id peer.ID) peer.AddrInfo {
if dht.h.Network().Connectedness(id) == network.Connected {
if hasValidConnectedness(dht.h, id) {
return dht.h.Peerstore().PeerInfo(id)
}
return peer.AddrInfo{}
}

func (dht *FullRT) maybeAddAddrs(p peer.ID, addrs []multiaddr.Multiaddr, ttl time.Duration) {
// Don't add addresses for self or our connected peers. We have better ones.
if p == dht.h.ID() || dht.h.Network().Connectedness(p) == network.Connected {
if p == dht.h.ID() || hasValidConnectedness(dht.h, p) {
return
}
dht.h.Peerstore().AddAddrs(p, addrs, ttl)
}

func hasValidConnectedness(host host.Host, id peer.ID) bool {
connectedness := host.Network().Connectedness(id)
return connectedness == network.Connected || connectedness == network.Limited
}
8 changes: 4 additions & 4 deletions query_test.go
Original file line number Diff line number Diff line change
@@ -39,10 +39,10 @@ func TestRTEvictionOnFailedQuery(t *testing.T) {
return nil
}))

// close both hosts so query fails
require.NoError(t, d1.host.Close())
require.NoError(t, d2.host.Close())
// peers will still be in the RT because we have decoupled membership from connectivity
// clear the addresses of the peers so that the next queries fail
d1.host.Peerstore().ClearAddrs(d2.self)
d2.host.Peerstore().ClearAddrs(d1.self)
// peers will still be in the RT because RT is decoupled with the host and peerstore
require.NoError(t, tu.WaitFor(ctx, func() error {
if !checkRoutingTable(d1, d2) {
return fmt.Errorf("should have routes")
6 changes: 2 additions & 4 deletions routing.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import (
"sync"
"time"

"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p/core/routing"
@@ -664,7 +663,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (pi peer.AddrInfo,
return peers, err
},
func(*qpeerset.QueryPeerset) bool {
return dht.host.Network().Connectedness(id) == network.Connected
return hasValidConnectedness(dht.host, id)
},
)

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

// Return peer information if we tried to dial the peer during the query or we are (or recently were) connected
// to the peer.
connectedness := dht.host.Network().Connectedness(id)
if dialedPeerDuringQuery || connectedness == network.Connected {
if dialedPeerDuringQuery || hasValidConnectedness(dht.host, id) {
return dht.peerstore.PeerInfo(id), nil
}

2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.26.0"
"version": "v0.26.1"
}