Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.11.0 rc2 #8582

Merged
merged 3 commits into from
Dec 3, 2021
Merged
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
13 changes: 11 additions & 2 deletions core/corehttp/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,18 @@ func (c IpfsNodeCollector) PeersTotalValues() map[string]float64 {
if c.Node.PeerHost == nil {
return vals
}
for _, conn := range c.Node.PeerHost.Network().Conns() {
for _, peerID := range c.Node.PeerHost.Network().Peers() {
// Each peer may have more than one connection (see for an explanation
// https://github.com/libp2p/go-libp2p-swarm/commit/0538806), so we grab
// only one, the first (an arbitrary and non-deterministic choice), which
// according to ConnsToPeer is the oldest connection in the list
// (https://github.com/libp2p/go-libp2p-swarm/blob/v0.2.6/swarm.go#L362-L364).
conns := c.Node.PeerHost.Network().ConnsToPeer(peerID)
if len(conns) == 0 {
continue
}
tr := ""
for _, proto := range conn.RemoteMultiaddr().Protocols() {
for _, proto := range conns[0].RemoteMultiaddr().Protocols() {
tr = tr + "/" + proto.Name
}
vals[tr] = vals[tr] + 1
Expand Down
12 changes: 7 additions & 5 deletions core/corehttp/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ func TestPeersTotal(t *testing.T) {

node := &core.IpfsNode{PeerHost: hosts[0]}
collector := IpfsNodeCollector{Node: node}
actual := collector.PeersTotalValues()
if len(actual) != 1 {
t.Fatalf("expected 1 peers transport, got %d, transport map %v", len(actual), actual)
peersTransport := collector.PeersTotalValues()
if len(peersTransport) > 2 {
t.Fatalf("expected at most 2 peers transport (tcp and upd/quic), got %d, transport map %v",
len(peersTransport), peersTransport)
}
if actual["/ip4/tcp"] != float64(3) {
t.Fatalf("expected 3 peers, got %f", actual["/ip4/tcp"])
totalPeers := peersTransport["/ip4/tcp"] + peersTransport["/ip4/udp/quic"]
if totalPeers != 3 {
t.Fatalf("expected 3 peers in either tcp or upd/quic transport, got %f", totalPeers)
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/ipfs/go-datastore v0.5.1
github.com/ipfs/go-detect-race v0.0.1
github.com/ipfs/go-ds-badger v0.3.0
github.com/ipfs/go-ds-flatfs v0.5.0
github.com/ipfs/go-ds-flatfs v0.5.1
github.com/ipfs/go-ds-leveldb v0.5.0
github.com/ipfs/go-ds-measure v0.2.0
github.com/ipfs/go-fetcher v1.6.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ github.com/ipfs/go-ds-badger v0.2.3/go.mod h1:pEYw0rgg3FIrywKKnL+Snr+w/LjJZVMTBR
github.com/ipfs/go-ds-badger v0.2.7/go.mod h1:02rnztVKA4aZwDuaRPTf8mpqcKmXP7mLl6JPxd14JHA=
github.com/ipfs/go-ds-badger v0.3.0 h1:xREL3V0EH9S219kFFueOYJJTcjgNSZ2HY1iSvN7U1Ro=
github.com/ipfs/go-ds-badger v0.3.0/go.mod h1:1ke6mXNqeV8K3y5Ak2bAA0osoTfmxUdupVCGm4QUIek=
github.com/ipfs/go-ds-flatfs v0.5.0 h1:ntq2P05cC51VOSZ0VO/HRaCoLefVXNKGRu9gYr9Ajko=
github.com/ipfs/go-ds-flatfs v0.5.0/go.mod h1:RWTV7oZD/yZYBKdbVIFXTX2fdY2Tbvl94NsWqmoyAX4=
github.com/ipfs/go-ds-flatfs v0.5.1 h1:ZCIO/kQOS/PSh3vcF1H6a8fkRGS7pOfwfPdx4n/KJH4=
github.com/ipfs/go-ds-flatfs v0.5.1/go.mod h1:RWTV7oZD/yZYBKdbVIFXTX2fdY2Tbvl94NsWqmoyAX4=
github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc=
github.com/ipfs/go-ds-leveldb v0.1.0/go.mod h1:hqAW8y4bwX5LWcCtku2rFNX3vjDZCy5LZCg+cSZvYb8=
github.com/ipfs/go-ds-leveldb v0.4.1/go.mod h1:jpbku/YqBSsBc1qgME8BkWS4AxzF2cEu1Ii2r79Hh9s=
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package ipfs
var CurrentCommit string

// CurrentVersionNumber is the current application's version literal
const CurrentVersionNumber = "0.11.0-rc1"
const CurrentVersionNumber = "0.11.0-rc2"

const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"

Expand Down