Dependency upgrades (#1755)

* Update go-libp2p to v0.22.0

* Testing with go1.19

* build(deps): bump github.com/multiformats/go-multicodec

Bumps [github.com/multiformats/go-multicodec](https://github.com/multiformats/go-multicodec) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/multiformats/go-multicodec/releases)
- [Commits](https://github.com/multiformats/go-multicodec/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/multiformats/go-multicodec
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/ipld/go-car from 0.4.0 to 0.5.0

Bumps [github.com/ipld/go-car](https://github.com/ipld/go-car) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/ipld/go-car/releases)
- [Commits](https://github.com/ipld/go-car/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: github.com/ipld/go-car
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/prometheus/client_golang

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.12.2 to 1.13.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.12.2...v1.13.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/hashicorp/go-hclog from 1.2.1 to 1.3.0

Bumps [github.com/hashicorp/go-hclog](https://github.com/hashicorp/go-hclog) from 1.2.1 to 1.3.0.
- [Release notes](https://github.com/hashicorp/go-hclog/releases)
- [Commits](https://github.com/hashicorp/go-hclog/compare/v1.2.1...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-hclog
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/ipfs/go-ds-crdt from 0.3.6 to 0.3.7

Bumps [github.com/ipfs/go-ds-crdt](https://github.com/ipfs/go-ds-crdt) from 0.3.6 to 0.3.7.
- [Release notes](https://github.com/ipfs/go-ds-crdt/releases)
- [Commits](https://github.com/ipfs/go-ds-crdt/compare/v0.3.6...v0.3.7)

---
updated-dependencies:
- dependency-name: github.com/ipfs/go-ds-crdt
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/urfave/cli/v2 from 2.10.2 to 2.14.1

Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.10.2 to 2.14.1.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v2.10.2...v2.14.1)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/libp2p/go-libp2p-http from 0.3.0 to 0.4.0

Bumps [github.com/libp2p/go-libp2p-http](https://github.com/libp2p/go-libp2p-http) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/libp2p/go-libp2p-http/releases)
- [Commits](https://github.com/libp2p/go-libp2p-http/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: github.com/libp2p/go-libp2p-http
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/libp2p/go-libp2p-gorpc from 0.4.0 to 0.5.0

Bumps [github.com/libp2p/go-libp2p-gorpc](https://github.com/libp2p/go-libp2p-gorpc) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/libp2p/go-libp2p-gorpc/releases)
- [Commits](https://github.com/libp2p/go-libp2p-gorpc/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: github.com/libp2p/go-libp2p-gorpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump contrib.go.opencensus.io/exporter/prometheus

Bumps [contrib.go.opencensus.io/exporter/prometheus](https://github.com/census-ecosystem/opencensus-go-exporter-prometheus) from 0.4.1 to 0.4.2.
- [Release notes](https://github.com/census-ecosystem/opencensus-go-exporter-prometheus/releases)
- [Commits](https://github.com/census-ecosystem/opencensus-go-exporter-prometheus/compare/v0.4.1...v0.4.2)

---
updated-dependencies:
- dependency-name: contrib.go.opencensus.io/exporter/prometheus
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/libp2p/go-libp2p-raft from 0.1.8 to 0.2.0

Bumps [github.com/libp2p/go-libp2p-raft](https://github.com/libp2p/go-libp2p-raft) from 0.1.8 to 0.2.0.
- [Release notes](https://github.com/libp2p/go-libp2p-raft/releases)
- [Commits](https://github.com/libp2p/go-libp2p-raft/compare/v0.1.8...v0.2.0)

---
updated-dependencies:
- dependency-name: github.com/libp2p/go-libp2p-raft
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump github.com/urfave/cli from 1.22.9 to 1.22.10

Bumps [github.com/urfave/cli](https://github.com/urfave/cli) from 1.22.9 to 1.22.10.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v1.22.9...v1.22.10)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix checker/linter/staticcheck warnings

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Hector Sanjuan 2022-09-06 16:57:17 +02:00 committed by GitHub
parent 8c93d4cb81
commit 5452b59a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
87 changed files with 506 additions and 622 deletions

View File

@ -7,7 +7,7 @@ on:
branches: [ master, dependency-upgrades ] branches: [ master, dependency-upgrades ]
env: env:
GO: 1.18 GO: 1.19
jobs: jobs:
tests-all: tests-all:

View File

@ -1,4 +1,4 @@
FROM golang:1.18-buster AS builder FROM golang:1.19-buster AS builder
MAINTAINER Hector Sanjuan <hector@protocol.ai> MAINTAINER Hector Sanjuan <hector@protocol.ai>
# This dockerfile builds and runs ipfs-cluster-service. # This dockerfile builds and runs ipfs-cluster-service.

View File

@ -1,4 +1,4 @@
FROM golang:1.18-buster AS builder FROM golang:1.19-buster AS builder
MAINTAINER Hector Sanjuan <hector@protocol.ai> MAINTAINER Hector Sanjuan <hector@protocol.ai>
# This dockerfile builds cluster and runs it along with go-ipfs. # This dockerfile builds cluster and runs it along with go-ipfs.

View File

@ -1,4 +1,4 @@
FROM golang:1.18-buster AS builder FROM golang:1.19-buster AS builder
MAINTAINER Hector Sanjuan <hector@protocol.ai> MAINTAINER Hector Sanjuan <hector@protocol.ai>
# This build state just builds the cluster binaries # This build state just builds the cluster binaries

View File

@ -13,7 +13,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/adder" "github.com/ipfs-cluster/ipfs-cluster/adder"
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
func TestAdd(t *testing.T) { func TestAdd(t *testing.T) {

View File

@ -14,7 +14,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs/go-unixfs" "github.com/ipfs/go-unixfs"
"github.com/ipld/go-car" "github.com/ipld/go-car"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
files "github.com/ipfs/go-ipfs-files" files "github.com/ipfs/go-ipfs-files"

View File

@ -12,7 +12,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
"github.com/ipld/go-car" "github.com/ipld/go-car"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
files "github.com/ipfs/go-ipfs-files" files "github.com/ipfs/go-ipfs-files"

View File

@ -23,7 +23,7 @@ import (
balanced "github.com/ipfs/go-unixfs/importer/balanced" balanced "github.com/ipfs/go-unixfs/importer/balanced"
ihelper "github.com/ipfs/go-unixfs/importer/helpers" ihelper "github.com/ipfs/go-unixfs/importer/helpers"
trickle "github.com/ipfs/go-unixfs/importer/trickle" trickle "github.com/ipfs/go-unixfs/importer/trickle"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
var log = logging.Logger("coreunix") var log = logging.Logger("coreunix")

View File

@ -81,7 +81,7 @@ func makeDAGSimple(ctx context.Context, dagObj map[string]cid.Cid) (ipld.Node, e
// recursively pinned to track the shard // recursively pinned to track the shard
func makeDAG(ctx context.Context, dagObj map[string]cid.Cid) ([]ipld.Node, error) { func makeDAG(ctx context.Context, dagObj map[string]cid.Cid) ([]ipld.Node, error) {
// FIXME: We have a 4MB limit on the block size enforced by bitswap: // FIXME: We have a 4MB limit on the block size enforced by bitswap:
// https://github.com/libp2p/go-libp2p-core/blob/master/network/network.go#L23 // https://github.com/libp2p/go-libp2p/core/blob/master/network/network.go#L23
// No indirect node // No indirect node
if len(dagObj) <= MaxLinks { if len(dagObj) <= MaxLinks {

View File

@ -17,7 +17,7 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -12,7 +12,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -10,7 +10,7 @@ import (
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
humanize "github.com/dustin/go-humanize" humanize "github.com/dustin/go-humanize"

View File

@ -12,7 +12,7 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -11,7 +11,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -10,7 +10,7 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -5,7 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
"go.opencensus.io/trace" "go.opencensus.io/trace"

View File

@ -14,7 +14,7 @@ import (
api "github.com/ipfs-cluster/ipfs-cluster/api" api "github.com/ipfs-cluster/ipfs-cluster/api"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -7,7 +7,7 @@ import (
api "github.com/ipfs-cluster/ipfs-cluster/api" api "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
func makeMetric(name, value string, weight int64, peer peer.ID, partitionable bool) api.Metric { func makeMetric(name, value string, weight int64, peer peer.ID, partitionable bool) api.Metric {

View File

@ -7,7 +7,7 @@ import (
"strconv" "strconv"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
// DefaultShardSize is the shard size for params objects created with DefaultParams(). // DefaultShardSize is the shard size for params objects created with DefaultParams().

View File

@ -33,8 +33,8 @@ import (
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
gopath "github.com/ipfs/go-path" gopath "github.com/ipfs/go-path"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
gostream "github.com/libp2p/go-libp2p-gostream" gostream "github.com/libp2p/go-libp2p-gostream"
p2phttp "github.com/libp2p/go-libp2p-http" p2phttp "github.com/libp2p/go-libp2p-http"

View File

@ -11,10 +11,9 @@ import (
"path/filepath" "path/filepath"
"time" "time"
ipfsconfig "github.com/ipfs/go-ipfs-config"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
crypto "github.com/libp2p/go-libp2p-core/crypto" crypto "github.com/libp2p/go-libp2p/core/crypto"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
@ -110,7 +109,7 @@ type Config struct {
} }
type jsonConfig struct { type jsonConfig struct {
HTTPListenMultiaddress ipfsconfig.Strings `json:"http_listen_multiaddress"` HTTPListenMultiaddress config.Strings `json:"http_listen_multiaddress"`
SSLCertFile string `json:"ssl_cert_file,omitempty"` SSLCertFile string `json:"ssl_cert_file,omitempty"`
SSLKeyFile string `json:"ssl_key_file,omitempty"` SSLKeyFile string `json:"ssl_key_file,omitempty"`
ReadTimeout string `json:"read_timeout"` ReadTimeout string `json:"read_timeout"`
@ -119,7 +118,7 @@ type jsonConfig struct {
IdleTimeout string `json:"idle_timeout"` IdleTimeout string `json:"idle_timeout"`
MaxHeaderBytes int `json:"max_header_bytes"` MaxHeaderBytes int `json:"max_header_bytes"`
Libp2pListenMultiaddress ipfsconfig.Strings `json:"libp2p_listen_multiaddress,omitempty"` Libp2pListenMultiaddress config.Strings `json:"libp2p_listen_multiaddress,omitempty"`
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
PrivateKey string `json:"private_key,omitempty" hidden:"true"` PrivateKey string `json:"private_key,omitempty" hidden:"true"`
@ -404,7 +403,7 @@ func (cfg *Config) toJSONConfig() (jcfg *jsonConfig, err error) {
} }
if cfg.ID != "" { if cfg.ID != "" {
jcfg.ID = peer.Encode(cfg.ID) jcfg.ID = cfg.ID.String()
} }
if cfg.PrivateKey != nil { if cfg.PrivateKey != nil {
pkeyBytes, err := crypto.MarshalPrivateKey(cfg.PrivateKey) pkeyBytes, err := crypto.MarshalPrivateKey(cfg.PrivateKey)

View File

@ -9,8 +9,8 @@ import (
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
types "github.com/ipfs-cluster/ipfs-cluster/api" types "github.com/ipfs-cluster/ipfs-cluster/api"
crypto "github.com/libp2p/go-libp2p-core/crypto" crypto "github.com/libp2p/go-libp2p/core/crypto"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )

View File

@ -9,17 +9,16 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os"
"reflect" "reflect"
"strings" "strings"
"testing" "testing"
"github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
peerstore "github.com/libp2p/go-libp2p-core/peerstore"
p2phttp "github.com/libp2p/go-libp2p-http" p2phttp "github.com/libp2p/go-libp2p-http"
"github.com/libp2p/go-libp2p/core/host"
peerstore "github.com/libp2p/go-libp2p/core/peerstore"
) )
var ( var (
@ -38,7 +37,7 @@ func ProcessResp(t *testing.T, httpResp *http.Response, err error, resp interfac
if err != nil { if err != nil {
t.Fatal("error making request: ", err) t.Fatal("error making request: ", err)
} }
body, err := ioutil.ReadAll(httpResp.Body) body, err := io.ReadAll(httpResp.Body)
defer httpResp.Body.Close() defer httpResp.Body.Close()
if err != nil { if err != nil {
t.Fatal("error reading body: ", err) t.Fatal("error reading body: ", err)
@ -140,7 +139,7 @@ func HTTPURL(a API) string {
// P2pURL returns the libp2p endpoint of the API. // P2pURL returns the libp2p endpoint of the API.
func P2pURL(a API) string { func P2pURL(a API) string {
return fmt.Sprintf("libp2p://%s", peer.Encode(a.Host().ID())) return fmt.Sprintf("libp2p://%s", a.Host().ID().String())
} }
// HttpsURL returns the HTTPS endpoint of the API // HttpsURL returns the HTTPS endpoint of the API
@ -160,7 +159,7 @@ func HTTPClient(t *testing.T, h host.Host, isHTTPS bool) *http.Client {
tr := &http.Transport{} tr := &http.Transport{}
if isHTTPS { if isHTTPS {
certpool := x509.NewCertPool() certpool := x509.NewCertPool()
cert, err := ioutil.ReadFile(SSLCertFile) cert, err := os.ReadFile(SSLCertFile)
if err != nil { if err != nil {
t.Fatal("error reading cert for https client: ", err) t.Fatal("error reading cert for https client: ", err)
} }

View File

@ -7,7 +7,6 @@ import (
"path/filepath" "path/filepath"
"time" "time"
ipfsconfig "github.com/ipfs/go-ipfs-config"
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
@ -98,7 +97,7 @@ type Config struct {
} }
type jsonConfig struct { type jsonConfig struct {
ListenMultiaddress ipfsconfig.Strings `json:"listen_multiaddress"` ListenMultiaddress config.Strings `json:"listen_multiaddress"`
NodeMultiaddress string `json:"node_multiaddress"` NodeMultiaddress string `json:"node_multiaddress"`
NodeHTTPS bool `json:"node_https,omitempty"` NodeHTTPS bool `json:"node_https,omitempty"`

View File

@ -31,7 +31,7 @@ import (
cmd "github.com/ipfs/go-ipfs-cmds" cmd "github.com/ipfs/go-ipfs-cmds"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
path "github.com/ipfs/go-path" path "github.com/ipfs/go-path"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
madns "github.com/multiformats/go-multiaddr-dns" madns "github.com/multiformats/go-multiaddr-dns"
manet "github.com/multiformats/go-multiaddr/net" manet "github.com/multiformats/go-multiaddr/net"

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -65,7 +64,7 @@ func TestIPFSProxyVersion(t *testing.T) {
t.Fatal("should forward requests to ipfs host: ", err) t.Fatal("should forward requests to ipfs host: ", err)
} }
defer res.Body.Close() defer res.Body.Close()
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
if res.StatusCode != http.StatusOK { if res.StatusCode != http.StatusOK {
t.Error("the request should have succeeded") t.Error("the request should have succeeded")
t.Fatal(string(resBytes)) t.Fatal(string(resBytes))
@ -170,7 +169,7 @@ func TestIPFSProxyPin(t *testing.T) {
t.Errorf("statusCode: got = %v, want %v", res.StatusCode, tt.args.statusCode) t.Errorf("statusCode: got = %v, want %v", res.StatusCode, tt.args.statusCode)
} }
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
switch tt.wantErr { switch tt.wantErr {
case false: case false:
@ -283,7 +282,7 @@ func TestIPFSProxyUnpin(t *testing.T) {
t.Errorf("statusCode: got = %v, want %v", res.StatusCode, tt.args.statusCode) t.Errorf("statusCode: got = %v, want %v", res.StatusCode, tt.args.statusCode)
} }
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
switch tt.wantErr { switch tt.wantErr {
case false: case false:
@ -352,7 +351,7 @@ func TestIPFSProxyPinUpdate(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
var resp ipfsPinOpResp var resp ipfsPinOpResp
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
err = json.Unmarshal(resBytes, &resp) err = json.Unmarshal(resBytes, &resp)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -378,7 +377,7 @@ func TestIPFSProxyPinUpdate(t *testing.T) {
t.Fatal("request should error") t.Fatal("request should error")
} }
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
var respErr cmd.Error var respErr cmd.Error
err = json.Unmarshal(resBytes, &respErr) err = json.Unmarshal(resBytes, &respErr)
if err != nil { if err != nil {
@ -404,7 +403,7 @@ func TestIPFSProxyPinUpdate(t *testing.T) {
t.Fatal("request should error") t.Fatal("request should error")
} }
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
var respErr cmd.Error var respErr cmd.Error
err = json.Unmarshal(resBytes, &respErr) err = json.Unmarshal(resBytes, &respErr)
if err != nil { if err != nil {
@ -433,7 +432,7 @@ func TestIPFSProxyPinLs(t *testing.T) {
t.Error("the request should have succeeded") t.Error("the request should have succeeded")
} }
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
var resp ipfsPinLsResp var resp ipfsPinLsResp
err = json.Unmarshal(resBytes, &resp) err = json.Unmarshal(resBytes, &resp)
if err != nil { if err != nil {
@ -456,7 +455,7 @@ func TestIPFSProxyPinLs(t *testing.T) {
t.Error("the request should have succeeded") t.Error("the request should have succeeded")
} }
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
var resp ipfsPinLsResp var resp ipfsPinLsResp
err = json.Unmarshal(resBytes, &resp) err = json.Unmarshal(resBytes, &resp)
if err != nil { if err != nil {
@ -479,7 +478,7 @@ func TestIPFSProxyPinLs(t *testing.T) {
t.Error("the request should have succeeded") t.Error("the request should have succeeded")
} }
resBytes, _ := ioutil.ReadAll(res2.Body) resBytes, _ := io.ReadAll(res2.Body)
var resp ipfsPinLsResp var resp ipfsPinLsResp
err = json.Unmarshal(resBytes, &resp) err = json.Unmarshal(resBytes, &resp)
if err != nil { if err != nil {
@ -518,7 +517,7 @@ func TestProxyRepoStat(t *testing.T) {
t.Error("request should have succeeded") t.Error("request should have succeeded")
} }
resBytes, _ := ioutil.ReadAll(res.Body) resBytes, _ := io.ReadAll(res.Body)
var stat api.IPFSRepoStat var stat api.IPFSRepoStat
err = json.Unmarshal(resBytes, &stat) err = json.Unmarshal(resBytes, &stat)
if err != nil { if err != nil {

View File

@ -22,8 +22,8 @@ import (
"go.uber.org/multierr" "go.uber.org/multierr"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -15,9 +15,9 @@ import (
shell "github.com/ipfs/go-ipfs-api" shell "github.com/ipfs/go-ipfs-api"
files "github.com/ipfs/go-ipfs-files" files "github.com/ipfs/go-ipfs-files"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
pnet "github.com/libp2p/go-libp2p-core/pnet" pnet "github.com/libp2p/go-libp2p/core/pnet"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns" madns "github.com/multiformats/go-multiaddr-dns"
manet "github.com/multiformats/go-multiaddr/net" manet "github.com/multiformats/go-multiaddr/net"

View File

@ -10,8 +10,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
peer "github.com/libp2p/go-libp2p-core/peer" pnet "github.com/libp2p/go-libp2p/core/pnet"
pnet "github.com/libp2p/go-libp2p-core/pnet"
tcp "github.com/libp2p/go-libp2p/p2p/transport/tcp" tcp "github.com/libp2p/go-libp2p/p2p/transport/tcp"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@ -60,7 +59,7 @@ func apiMAddr(a *rest.API) ma.Multiaddr {
} }
func peerMAddr(a *rest.API) ma.Multiaddr { func peerMAddr(a *rest.API) ma.Multiaddr {
ipfsAddr, _ := ma.NewMultiaddr(fmt.Sprintf("/p2p/%s", peer.Encode(a.Host().ID()))) ipfsAddr, _ := ma.NewMultiaddr(fmt.Sprintf("/p2p/%s", a.Host().ID().String()))
for _, a := range a.Host().Addrs() { for _, a := range a.Host().Addrs() {
if _, err := a.ValueForProtocol(ma.P_IP4); err == nil { if _, err := a.ValueForProtocol(ma.P_IP4); err == nil {
return a.Encapsulate(ipfsAddr) return a.Encapsulate(ipfsAddr)

View File

@ -7,7 +7,7 @@ import (
shell "github.com/ipfs/go-ipfs-api" shell "github.com/ipfs/go-ipfs-api"
files "github.com/ipfs/go-ipfs-files" files "github.com/ipfs/go-ipfs-files"
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
// loadBalancingClient is a client to interact with IPFS Cluster APIs // loadBalancingClient is a client to interact with IPFS Cluster APIs

View File

@ -17,7 +17,7 @@ import (
files "github.com/ipfs/go-ipfs-files" files "github.com/ipfs/go-ipfs-files"
gopath "github.com/ipfs/go-path" gopath "github.com/ipfs/go-path"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
"go.opencensus.io/trace" "go.opencensus.io/trace"
) )
@ -62,8 +62,7 @@ func (c *defaultClient) PeerAdd(ctx context.Context, pid peer.ID) (api.ID, error
ctx, span := trace.StartSpan(ctx, "client/PeerAdd") ctx, span := trace.StartSpan(ctx, "client/PeerAdd")
defer span.End() defer span.End()
pidStr := peer.Encode(pid) body := peerAddBody{pid.String()}
body := peerAddBody{pidStr}
var buf bytes.Buffer var buf bytes.Buffer
enc := json.NewEncoder(&buf) enc := json.NewEncoder(&buf)

View File

@ -11,8 +11,8 @@ import (
rest "github.com/ipfs-cluster/ipfs-cluster/api/rest" rest "github.com/ipfs-cluster/ipfs-cluster/api/rest"
test "github.com/ipfs-cluster/ipfs-cluster/test" test "github.com/ipfs-cluster/ipfs-cluster/test"
peer "github.com/libp2p/go-libp2p-core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
peer "github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@ -510,7 +510,7 @@ func TestAlerts(t *testing.T) {
if len(alerts) != 1 { if len(alerts) != 1 {
t.Fatal("expected 1 alert") t.Fatal("expected 1 alert")
} }
pID2 := peer.Encode(test.PeerID2) pID2 := test.PeerID2.String()
if alerts[0].Peer != test.PeerID2 { if alerts[0].Peer != test.PeerID2 {
t.Errorf("expected an alert from %s", pID2) t.Errorf("expected an alert from %s", pID2)
} }
@ -596,19 +596,19 @@ func (wait *waitService) Status(ctx context.Context, in types.Cid, out *types.Gl
*out = types.GlobalPinInfo{ *out = types.GlobalPinInfo{
Cid: in, Cid: in,
PeerMap: map[string]types.PinInfoShort{ PeerMap: map[string]types.PinInfoShort{
peer.Encode(test.PeerID1): { test.PeerID1.String(): {
Status: types.TrackerStatusPinned, Status: types.TrackerStatusPinned,
TS: wait.pinStart, TS: wait.pinStart,
}, },
peer.Encode(test.PeerID2): { test.PeerID2.String(): {
Status: types.TrackerStatusPinned, Status: types.TrackerStatusPinned,
TS: wait.pinStart, TS: wait.pinStart,
}, },
peer.Encode(test.PeerID3): { test.PeerID3.String(): {
Status: types.TrackerStatusPinning, Status: types.TrackerStatusPinning,
TS: wait.pinStart, TS: wait.pinStart,
}, },
peer.Encode(test.PeerID3): { test.PeerID3.String(): {
Status: types.TrackerStatusRemote, Status: types.TrackerStatusRemote,
TS: wait.pinStart, TS: wait.pinStart,
}, },
@ -618,19 +618,19 @@ func (wait *waitService) Status(ctx context.Context, in types.Cid, out *types.Gl
*out = types.GlobalPinInfo{ *out = types.GlobalPinInfo{
Cid: in, Cid: in,
PeerMap: map[string]types.PinInfoShort{ PeerMap: map[string]types.PinInfoShort{
peer.Encode(test.PeerID1): { test.PeerID1.String(): {
Status: types.TrackerStatusPinning, Status: types.TrackerStatusPinning,
TS: wait.pinStart, TS: wait.pinStart,
}, },
peer.Encode(test.PeerID2): { test.PeerID2.String(): {
Status: types.TrackerStatusPinned, Status: types.TrackerStatusPinned,
TS: wait.pinStart, TS: wait.pinStart,
}, },
peer.Encode(test.PeerID3): { test.PeerID3.String(): {
Status: types.TrackerStatusPinning, Status: types.TrackerStatusPinning,
TS: wait.pinStart, TS: wait.pinStart,
}, },
peer.Encode(test.PeerID3): { test.PeerID3.String(): {
Status: types.TrackerStatusRemote, Status: types.TrackerStatusRemote,
TS: wait.pinStart, TS: wait.pinStart,
}, },
@ -668,11 +668,11 @@ func (wait *waitServiceUnpin) Status(ctx context.Context, in types.Cid, out *typ
*out = types.GlobalPinInfo{ *out = types.GlobalPinInfo{
Cid: in, Cid: in,
PeerMap: map[string]types.PinInfoShort{ PeerMap: map[string]types.PinInfoShort{
peer.Encode(test.PeerID1): { test.PeerID1.String(): {
Status: types.TrackerStatusUnpinned, Status: types.TrackerStatusUnpinned,
TS: wait.unpinStart, TS: wait.unpinStart,
}, },
peer.Encode(test.PeerID2): { test.PeerID2.String(): {
Status: types.TrackerStatusUnpinned, Status: types.TrackerStatusUnpinned,
TS: wait.unpinStart, TS: wait.unpinStart,
}, },
@ -682,11 +682,11 @@ func (wait *waitServiceUnpin) Status(ctx context.Context, in types.Cid, out *typ
*out = types.GlobalPinInfo{ *out = types.GlobalPinInfo{
Cid: in, Cid: in,
PeerMap: map[string]types.PinInfoShort{ PeerMap: map[string]types.PinInfoShort{
peer.Encode(test.PeerID1): { test.PeerID1.String(): {
Status: types.TrackerStatusUnpinning, Status: types.TrackerStatusUnpinning,
TS: wait.unpinStart, TS: wait.unpinStart,
}, },
peer.Encode(test.PeerID2): { test.PeerID2.String(): {
Status: types.TrackerStatusUnpinning, Status: types.TrackerStatusUnpinning,
TS: wait.unpinStart, TS: wait.unpinStart,
}, },

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"strings" "strings"
@ -89,7 +88,7 @@ func (c *defaultClient) doRequest(
return c.client.Do(r) return c.client.Do(r)
} }
func (c *defaultClient) handleResponse(resp *http.Response, obj interface{}) error { func (c *defaultClient) handleResponse(resp *http.Response, obj interface{}) error {
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
resp.Body.Close() resp.Body.Close()
if err != nil { if err != nil {

View File

@ -9,9 +9,9 @@ import (
"time" "time"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
peer "github.com/libp2p/go-libp2p-core/peer"
peerstore "github.com/libp2p/go-libp2p-core/peerstore"
p2phttp "github.com/libp2p/go-libp2p-http" p2phttp "github.com/libp2p/go-libp2p-http"
peer "github.com/libp2p/go-libp2p/core/peer"
peerstore "github.com/libp2p/go-libp2p/core/peerstore"
noise "github.com/libp2p/go-libp2p/p2p/security/noise" noise "github.com/libp2p/go-libp2p/p2p/security/noise"
libp2ptls "github.com/libp2p/go-libp2p/p2p/security/tls" libp2ptls "github.com/libp2p/go-libp2p/p2p/security/tls"
tcp "github.com/libp2p/go-libp2p/p2p/transport/tcp" tcp "github.com/libp2p/go-libp2p/p2p/transport/tcp"
@ -89,7 +89,7 @@ func (c *defaultClient) enableLibp2p() error {
c.transport.RegisterProtocol("libp2p", p2phttp.NewTransport(h)) c.transport.RegisterProtocol("libp2p", p2phttp.NewTransport(h))
c.net = "libp2p" c.net = "libp2p"
c.p2p = h c.p2p = h
c.hostname = peer.Encode(pinfo.ID) c.hostname = pinfo.ID.String()
return nil return nil
} }

View File

@ -22,9 +22,9 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api/common" "github.com/ipfs-cluster/ipfs-cluster/api/common"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
"github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p/core/peer"
mux "github.com/gorilla/mux" mux "github.com/gorilla/mux"
) )
@ -850,7 +850,7 @@ func (api *API) repoGCHandler(w http.ResponseWriter, r *http.Request) {
func repoGCToGlobal(r types.RepoGC) types.GlobalRepoGC { func repoGCToGlobal(r types.RepoGC) types.GlobalRepoGC {
return types.GlobalRepoGC{ return types.GlobalRepoGC{
PeerMap: map[string]types.RepoGC{ PeerMap: map[string]types.RepoGC{
peer.Encode(r.Peer): r, r.Peer.String(): r,
}, },
} }
} }

View File

@ -3,7 +3,7 @@ package rest
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -14,7 +14,7 @@ import (
clustertest "github.com/ipfs-cluster/ipfs-cluster/test" clustertest "github.com/ipfs-cluster/ipfs-cluster/test"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@ -247,7 +247,7 @@ func TestAPIAddFileEndpoint_StreamChannelsFalse(t *testing.T) {
tf := func(t *testing.T, url test.URLFunc) { tf := func(t *testing.T, url test.URLFunc) {
body, closer := sth.GetTreeMultiReader(t) body, closer := sth.GetTreeMultiReader(t)
defer closer.Close() defer closer.Close()
fullBody, err := ioutil.ReadAll(body) fullBody, err := io.ReadAll(body)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -301,10 +301,10 @@ func TestConnectGraphEndpoint(t *testing.T) {
// test a few link values // test a few link values
pid1 := clustertest.PeerID1 pid1 := clustertest.PeerID1
pid4 := clustertest.PeerID4 pid4 := clustertest.PeerID4
if _, ok := cg.ClustertoIPFS[peer.Encode(pid1)]; !ok { if _, ok := cg.ClustertoIPFS[pid1.String()]; !ok {
t.Fatal("missing cluster peer 1 from cluster to peer links map") t.Fatal("missing cluster peer 1 from cluster to peer links map")
} }
if cg.ClustertoIPFS[peer.Encode(pid1)] != pid4 { if cg.ClustertoIPFS[pid1.String()] != pid4 {
t.Error("unexpected ipfs peer mapped to cluster peer 1 in graph") t.Error("unexpected ipfs peer mapped to cluster peer 1 in graph")
} }
} }
@ -621,7 +621,7 @@ func TestAPIStatusAllEndpoint(t *testing.T) {
// mockPinTracker returns 3 items for Cluster.StatusAll // mockPinTracker returns 3 items for Cluster.StatusAll
if len(resp) != 3 || if len(resp) != 3 ||
!resp[0].Cid.Equals(clustertest.Cid1) || !resp[0].Cid.Equals(clustertest.Cid1) ||
resp[1].PeerMap[peer.Encode(clustertest.PeerID1)].Status.String() != "pinning" { resp[1].PeerMap[clustertest.PeerID1.String()].Status.String() != "pinning" {
t.Errorf("unexpected statusAll resp") t.Errorf("unexpected statusAll resp")
} }
@ -725,7 +725,7 @@ func TestAPIStatusEndpoint(t *testing.T) {
if !resp.Cid.Equals(clustertest.Cid1) { if !resp.Cid.Equals(clustertest.Cid1) {
t.Error("expected the same cid") t.Error("expected the same cid")
} }
info, ok := resp.PeerMap[peer.Encode(clustertest.PeerID1)] info, ok := resp.PeerMap[clustertest.PeerID1.String()]
if !ok { if !ok {
t.Fatal("expected info for clustertest.PeerID1") t.Fatal("expected info for clustertest.PeerID1")
} }
@ -740,7 +740,7 @@ func TestAPIStatusEndpoint(t *testing.T) {
if !resp2.Cid.Equals(clustertest.Cid1) { if !resp2.Cid.Equals(clustertest.Cid1) {
t.Error("expected the same cid") t.Error("expected the same cid")
} }
info, ok = resp2.PeerMap[peer.Encode(clustertest.PeerID2)] info, ok = resp2.PeerMap[clustertest.PeerID2.String()]
if !ok { if !ok {
t.Fatal("expected info for clustertest.PeerID2") t.Fatal("expected info for clustertest.PeerID2")
} }
@ -764,7 +764,7 @@ func TestAPIRecoverEndpoint(t *testing.T) {
if !resp.Cid.Equals(clustertest.Cid1) { if !resp.Cid.Equals(clustertest.Cid1) {
t.Error("expected the same cid") t.Error("expected the same cid")
} }
info, ok := resp.PeerMap[peer.Encode(clustertest.PeerID1)] info, ok := resp.PeerMap[clustertest.PeerID1.String()]
if !ok { if !ok {
t.Fatal("expected info for clustertest.PeerID1") t.Fatal("expected info for clustertest.PeerID1")
} }

View File

@ -21,8 +21,8 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
protocol "github.com/libp2p/go-libp2p-core/protocol" protocol "github.com/libp2p/go-libp2p/core/protocol"
multiaddr "github.com/multiformats/go-multiaddr" multiaddr "github.com/multiformats/go-multiaddr"
// needed to parse /ws multiaddresses // needed to parse /ws multiaddresses
@ -385,7 +385,7 @@ func (gpi *GlobalPinInfo) Add(pi PinInfo) {
gpi.PeerMap = make(map[string]PinInfoShort) gpi.PeerMap = make(map[string]PinInfoShort)
} }
gpi.PeerMap[peer.Encode(pi.Peer)] = pi.PinInfoShort gpi.PeerMap[pi.Peer.String()] = pi.PinInfoShort
} }
// Defined returns if the object is not empty. // Defined returns if the object is not empty.
@ -576,17 +576,19 @@ type IPFSID struct {
// A sharded Pin would look like: // A sharded Pin would look like:
// //
// [ Meta ] (not pinned on IPFS, only present in cluster state) // [ Meta ] (not pinned on IPFS, only present in cluster state)
//
// | // |
// v // v
//
// [ Cluster DAG ] (pinned everywhere in "direct") // [ Cluster DAG ] (pinned everywhere in "direct")
//
// | .. | // | .. |
// v v // v v
//
// [Shard1] .. [ShardN] (allocated to peers and pinned with max-depth=1 // [Shard1] .. [ShardN] (allocated to peers and pinned with max-depth=1
// | | .. | | | .. | // | | .. | | | .. |
// v v .. v v v .. v // v v .. v v v .. v
// [][]..[] [][]..[] Blocks (indirectly pinned on ipfs, not tracked in cluster) // [][]..[] [][]..[] Blocks (indirectly pinned on ipfs, not tracked in cluster)
//
//
type PinType uint64 type PinType uint64
// PinType values. See PinType documentation for further explanation. // PinType values. See PinType documentation for further explanation.

View File

@ -8,7 +8,7 @@ import (
"testing" "testing"
"time" "time"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
multiaddr "github.com/multiformats/go-multiaddr" multiaddr "github.com/multiformats/go-multiaddr"
"github.com/ugorji/go/codec" "github.com/ugorji/go/codec"

View File

@ -1,7 +1,7 @@
package api package api
import ( import (
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
// PeersToStrings Encodes a list of peers. // PeersToStrings Encodes a list of peers.
@ -9,7 +9,7 @@ func PeersToStrings(peers []peer.ID) []string {
strs := make([]string, len(peers)) strs := make([]string, len(peers))
for i, p := range peers { for i, p := range peers {
if p != "" { if p != "" {
strs[i] = peer.Encode(p) strs[i] = p.String()
} }
} }
return strs return strs

View File

@ -20,11 +20,11 @@ import (
"go.uber.org/multierr" "go.uber.org/multierr"
ds "github.com/ipfs/go-datastore" ds "github.com/ipfs/go-datastore"
host "github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-core/peer"
peerstore "github.com/libp2p/go-libp2p-core/peerstore"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
dual "github.com/libp2p/go-libp2p-kad-dht/dual" dual "github.com/libp2p/go-libp2p-kad-dht/dual"
host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p/core/peer"
peerstore "github.com/libp2p/go-libp2p/core/peerstore"
mdns "github.com/libp2p/go-libp2p/p2p/discovery/mdns" mdns "github.com/libp2p/go-libp2p/p2p/discovery/mdns"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
@ -1129,7 +1129,7 @@ func (c *Cluster) distances(ctx context.Context, exclude peer.ID) (*distanceChec
// StateSync performs maintenance tasks on the global state that require // StateSync performs maintenance tasks on the global state that require
// looping through all the items. It is triggered automatically on // looping through all the items. It is triggered automatically on
// StateSyncInterval. Currently it: // StateSyncInterval. Currently it:
// * Sends unpin for expired items for which this peer is "closest" // - Sends unpin for expired items for which this peer is "closest"
// (skipped for follower peers) // (skipped for follower peers)
func (c *Cluster) StateSync(ctx context.Context) error { func (c *Cluster) StateSync(ctx context.Context) error {
_, span := trace.StartSpan(ctx, "cluster/StateSync") _, span := trace.StartSpan(ctx, "cluster/StateSync")
@ -2261,7 +2261,7 @@ func (c *Cluster) RepoGC(ctx context.Context) (api.GlobalRepoGC, error) {
&repoGC, &repoGC,
) )
if err == nil { if err == nil {
globalRepoGC.PeerMap[peer.Encode(member)] = repoGC globalRepoGC.PeerMap[member.String()] = repoGC
continue continue
} }
@ -2274,7 +2274,7 @@ func (c *Cluster) RepoGC(ctx context.Context) (api.GlobalRepoGC, error) {
pv := pingValueFromMetric(c.monitor.LatestForPeer(c.ctx, pingMetricName, member)) pv := pingValueFromMetric(c.monitor.LatestForPeer(c.ctx, pingMetricName, member))
globalRepoGC.PeerMap[peer.Encode(member)] = api.RepoGC{ globalRepoGC.PeerMap[member.String()] = api.RepoGC{
Peer: member, Peer: member,
Peername: pv.Peername, Peername: pv.Peername,
Keys: []api.IPFSRepoGC{}, Keys: []api.IPFSRepoGC{},

View File

@ -13,8 +13,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/config" "github.com/ipfs-cluster/ipfs-cluster/config"
ipfsconfig "github.com/ipfs/go-ipfs-config" pnet "github.com/libp2p/go-libp2p/core/pnet"
pnet "github.com/libp2p/go-libp2p-core/pnet"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
@ -175,7 +174,7 @@ type configJSON struct {
PrivateKey string `json:"private_key,omitempty" hidden:"true"` PrivateKey string `json:"private_key,omitempty" hidden:"true"`
Secret string `json:"secret" hidden:"true"` Secret string `json:"secret" hidden:"true"`
LeaveOnShutdown bool `json:"leave_on_shutdown"` LeaveOnShutdown bool `json:"leave_on_shutdown"`
ListenMultiaddress ipfsconfig.Strings `json:"listen_multiaddress"` ListenMultiaddress config.Strings `json:"listen_multiaddress"`
EnableRelayHop bool `json:"enable_relay_hop"` EnableRelayHop bool `json:"enable_relay_hop"`
ConnectionManager *connMgrConfigJSON `json:"connection_manager"` ConnectionManager *connMgrConfigJSON `json:"connection_manager"`
DialPeerTimeout string `json:"dial_peer_timeout"` DialPeerTimeout string `json:"dial_peer_timeout"`
@ -503,11 +502,11 @@ func (cfg *Config) toConfigJSON() (jcfg *configJSON, err error) {
jcfg.ReplicationFactorMin = cfg.ReplicationFactorMin jcfg.ReplicationFactorMin = cfg.ReplicationFactorMin
jcfg.ReplicationFactorMax = cfg.ReplicationFactorMax jcfg.ReplicationFactorMax = cfg.ReplicationFactorMax
jcfg.LeaveOnShutdown = cfg.LeaveOnShutdown jcfg.LeaveOnShutdown = cfg.LeaveOnShutdown
var listenAddrs ipfsconfig.Strings var listenAddrs config.Strings
for _, addr := range cfg.ListenAddr { for _, addr := range cfg.ListenAddr {
listenAddrs = append(listenAddrs, addr.String()) listenAddrs = append(listenAddrs, addr.String())
} }
jcfg.ListenMultiaddress = ipfsconfig.Strings(listenAddrs) jcfg.ListenMultiaddress = config.Strings(listenAddrs)
jcfg.EnableRelayHop = cfg.EnableRelayHop jcfg.EnableRelayHop = cfg.EnableRelayHop
jcfg.ConnectionManager = &connMgrConfigJSON{ jcfg.ConnectionManager = &connMgrConfigJSON{
HighWater: cfg.ConnMgr.HighWater, HighWater: cfg.ConnMgr.HighWater,

View File

@ -6,7 +6,7 @@ import (
"testing" "testing"
"time" "time"
ipfsconfig "github.com/ipfs/go-ipfs-config" "github.com/ipfs-cluster/ipfs-cluster/config"
) )
var ccfgTestJSON = []byte(` var ccfgTestJSON = []byte(`
@ -134,7 +134,7 @@ func TestLoadJSON(t *testing.T) {
}) })
t.Run("bad listen multiaddress", func(t *testing.T) { t.Run("bad listen multiaddress", func(t *testing.T) {
_, err := loadJSON2(t, func(j *configJSON) { j.ListenMultiaddress = ipfsconfig.Strings{"abc"} }) _, err := loadJSON2(t, func(j *configJSON) { j.ListenMultiaddress = config.Strings{"abc"} })
if err == nil { if err == nil {
t.Error("expected error parsing listen_multiaddress") t.Error("expected error parsing listen_multiaddress")
} }

View File

@ -22,7 +22,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/version" "github.com/ipfs-cluster/ipfs-cluster/version"
gopath "github.com/ipfs/go-path" gopath "github.com/ipfs/go-path"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -9,11 +9,11 @@ import (
namespace "github.com/ipfs/go-datastore/namespace" namespace "github.com/ipfs/go-datastore/namespace"
ipns "github.com/ipfs/go-ipns" ipns "github.com/ipfs/go-ipns"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
crypto "github.com/libp2p/go-libp2p-core/crypto" crypto "github.com/libp2p/go-libp2p/core/crypto"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
network "github.com/libp2p/go-libp2p-core/network" network "github.com/libp2p/go-libp2p/core/network"
corepnet "github.com/libp2p/go-libp2p-core/pnet" corepnet "github.com/libp2p/go-libp2p/core/pnet"
routing "github.com/libp2p/go-libp2p-core/routing" routing "github.com/libp2p/go-libp2p/core/routing"
dht "github.com/libp2p/go-libp2p-kad-dht" dht "github.com/libp2p/go-libp2p-kad-dht"
dual "github.com/libp2p/go-libp2p-kad-dht/dual" dual "github.com/libp2p/go-libp2p-kad-dht/dual"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"

View File

@ -11,8 +11,6 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer"
humanize "github.com/dustin/go-humanize" humanize "github.com/dustin/go-humanize"
) )
@ -270,7 +268,7 @@ func textFormatPrintMetric(obj api.Metric) {
v = humanize.Bytes(uint64(obj.Weight)) v = humanize.Bytes(uint64(obj.Weight))
} }
fmt.Printf("%s | %s: %s | Expires in: %s\n", peer.Encode(obj.Peer), obj.Name, v, humanize.Time(time.Unix(0, obj.Expire))) fmt.Printf("%s | %s: %s | Expires in: %s\n", obj.Peer, obj.Name, v, humanize.Time(time.Unix(0, obj.Expire)))
} }
func textFormatPrintAlert(obj api.Alert) { func textFormatPrintAlert(obj api.Alert) {

View File

@ -7,7 +7,7 @@ import (
"sort" "sort"
dot "github.com/kishansagathiya/go-dot" dot "github.com/kishansagathiya/go-dot"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
) )
@ -45,8 +45,7 @@ func makeDot(cg api.ConnectGraph, w io.Writer, allIpfs bool) error {
for k, v := range cg.IPFSLinks { for k, v := range cg.IPFSLinks {
ipfsEdges[k] = make([]peer.ID, 0) ipfsEdges[k] = make([]peer.ID, 0)
for _, id := range v { for _, id := range v {
strPid := peer.Encode(id) strPid := id.String()
if _, ok := cg.IPFSLinks[strPid]; ok || allIpfs { if _, ok := cg.IPFSLinks[strPid]; ok || allIpfs {
ipfsEdges[k] = append(ipfsEdges[k], id) ipfsEdges[k] = append(ipfsEdges[k], id)
} }
@ -63,7 +62,7 @@ func makeDot(cg api.ConnectGraph, w io.Writer, allIpfs bool) error {
dW := dotWriter{ dW := dotWriter{
w: w, w: w,
dotGraph: dot.NewGraph("cluster"), dotGraph: dot.NewGraph("cluster"),
self: peer.Encode(cg.ClusterID), self: cg.ClusterID.String(),
trustMap: cg.ClusterTrustLinks, trustMap: cg.ClusterTrustLinks,
idToPeername: cg.IDtoPeername, idToPeername: cg.IDtoPeername,
ipfsEdges: ipfsEdges, ipfsEdges: ipfsEdges,
@ -205,7 +204,7 @@ func (dW *dotWriter) print() error {
v := dW.clusterEdges[k] v := dW.clusterEdges[k]
for _, id := range v { for _, id := range v {
toNode := dW.clusterNodes[k] toNode := dW.clusterNodes[k]
fromNode := dW.clusterNodes[peer.Encode(id)] fromNode := dW.clusterNodes[id.String()]
dW.dotGraph.AddEdge(toNode, fromNode, true, "") dW.dotGraph.AddEdge(toNode, fromNode, true, "")
} }
} }
@ -227,7 +226,7 @@ func (dW *dotWriter) print() error {
continue continue
} }
fromNode, ok = dW.ipfsNodes[peer.Encode(ipfsID)] fromNode, ok = dW.ipfsNodes[ipfsID.String()]
if !ok { if !ok {
logger.Error("expected a node at this id") logger.Error("expected a node at this id")
continue continue
@ -242,7 +241,7 @@ func (dW *dotWriter) print() error {
v := dW.ipfsEdges[k] v := dW.ipfsEdges[k]
toNode := dW.ipfsNodes[k] toNode := dW.ipfsNodes[k]
for _, id := range v { for _, id := range v {
idStr := peer.Encode(id) idStr := id.String()
fromNode, ok := dW.ipfsNodes[idStr] fromNode, ok := dW.ipfsNodes[idStr]
if !ok { if !ok {
logger.Error("expected a node here") logger.Error("expected a node here")

View File

@ -8,7 +8,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
func verifyOutput(t *testing.T, outStr string, trueStr string) { func verifyOutput(t *testing.T, outStr string, trueStr string) {
@ -83,37 +83,37 @@ func TestSimpleIpfsGraphs(t *testing.T) {
cg := api.ConnectGraph{ cg := api.ConnectGraph{
ClusterID: pid1, ClusterID: pid1,
ClusterLinks: map[string][]peer.ID{ ClusterLinks: map[string][]peer.ID{
peer.Encode(pid1): { pid1.String(): {
pid2, pid2,
pid3, pid3,
}, },
peer.Encode(pid2): { pid2.String(): {
pid1, pid1,
pid3, pid3,
}, },
peer.Encode(pid3): { pid3.String(): {
pid1, pid1,
pid2, pid2,
}, },
}, },
IPFSLinks: map[string][]peer.ID{ IPFSLinks: map[string][]peer.ID{
peer.Encode(pid4): { pid4.String(): {
pid5, pid5,
pid6, pid6,
}, },
peer.Encode(pid5): { pid5.String(): {
pid4, pid4,
pid6, pid6,
}, },
peer.Encode(pid6): { pid6.String(): {
pid4, pid4,
pid5, pid5,
}, },
}, },
ClustertoIPFS: map[string]peer.ID{ ClustertoIPFS: map[string]peer.ID{
peer.Encode(pid1): pid4, pid1.String(): pid4,
peer.Encode(pid2): pid5, pid2.String(): pid5,
peer.Encode(pid3): pid6, pid3.String(): pid6,
}, },
} }
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
@ -181,35 +181,35 @@ func TestIpfsAllGraphs(t *testing.T) {
cg := api.ConnectGraph{ cg := api.ConnectGraph{
ClusterID: pid1, ClusterID: pid1,
ClusterLinks: map[string][]peer.ID{ ClusterLinks: map[string][]peer.ID{
peer.Encode(pid1): { pid1.String(): {
pid2, pid2,
pid3, pid3,
}, },
peer.Encode(pid2): { pid2.String(): {
pid1, pid1,
pid3, pid3,
}, },
peer.Encode(pid3): { pid3.String(): {
pid1, pid1,
pid2, pid2,
}, },
}, },
IPFSLinks: map[string][]peer.ID{ IPFSLinks: map[string][]peer.ID{
peer.Encode(pid4): { pid4.String(): {
pid5, pid5,
pid6, pid6,
pid7, pid7,
pid8, pid8,
pid9, pid9,
}, },
peer.Encode(pid5): { pid5.String(): {
pid4, pid4,
pid6, pid6,
pid7, pid7,
pid8, pid8,
pid9, pid9,
}, },
peer.Encode(pid6): { pid6.String(): {
pid4, pid4,
pid5, pid5,
pid7, pid7,
@ -218,9 +218,9 @@ func TestIpfsAllGraphs(t *testing.T) {
}, },
}, },
ClustertoIPFS: map[string]peer.ID{ ClustertoIPFS: map[string]peer.ID{
peer.Encode(pid1): pid4, pid1.String(): pid4,
peer.Encode(pid2): pid5, pid2.String(): pid5,
peer.Encode(pid3): pid6, pid3.String(): pid6,
}, },
} }

View File

@ -16,7 +16,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api/rest/client" "github.com/ipfs-cluster/ipfs-cluster/api/rest/client"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
uuid "github.com/google/uuid" uuid "github.com/google/uuid"

View File

@ -24,8 +24,8 @@ import (
"go.opencensus.io/tag" "go.opencensus.io/tag"
ds "github.com/ipfs/go-datastore" ds "github.com/ipfs/go-datastore"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
dual "github.com/libp2p/go-libp2p-kad-dht/dual" dual "github.com/libp2p/go-libp2p-kad-dht/dual"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"

View File

@ -17,7 +17,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/cmdutils" "github.com/ipfs-cluster/ipfs-cluster/cmdutils"
"github.com/ipfs-cluster/ipfs-cluster/pstoremgr" "github.com/ipfs-cluster/ipfs-cluster/pstoremgr"
"github.com/ipfs-cluster/ipfs-cluster/version" "github.com/ipfs-cluster/ipfs-cluster/version"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
semver "github.com/blang/semver" semver "github.com/blang/semver"

View File

@ -16,7 +16,7 @@ import (
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
ipfscluster "github.com/ipfs-cluster/ipfs-cluster" ipfscluster "github.com/ipfs-cluster/ipfs-cluster"
ipfshttp "github.com/ipfs-cluster/ipfs-cluster/ipfsconn/ipfshttp" ipfshttp "github.com/ipfs-cluster/ipfs-cluster/ipfsconn/ipfshttp"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
dual "github.com/libp2p/go-libp2p-kad-dht/dual" dual "github.com/libp2p/go-libp2p-kad-dht/dual"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -8,8 +8,9 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"os"
"path/filepath" "path/filepath"
"sync" "sync"
"time" "time"
@ -347,7 +348,7 @@ func (cfg *Manager) Validate() error {
func (cfg *Manager) LoadJSONFromFile(path string) error { func (cfg *Manager) LoadJSONFromFile(path string) error {
cfg.path = path cfg.path = path
file, err := ioutil.ReadFile(path) file, err := os.ReadFile(path)
if err != nil { if err != nil {
logger.Error("error reading the configuration file: ", err) logger.Error("error reading the configuration file: ", err)
return err return err
@ -365,7 +366,7 @@ func (cfg *Manager) LoadJSONFromHTTPSource(url string) error {
return fmt.Errorf("%w: %s", errFetchingSource, url) return fmt.Errorf("%w: %s", errFetchingSource, url)
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }
@ -489,7 +490,7 @@ func (cfg *Manager) SaveJSON(path string) error {
return err return err
} }
return ioutil.WriteFile(cfg.path, bs, 0600) return os.WriteFile(cfg.path, bs, 0600)
} }
// ToJSON provides a JSON representation of the configuration by // ToJSON provides a JSON representation of the configuration by
@ -612,7 +613,7 @@ func (cfg *Manager) IsLoadedFromJSON(t SectionType, name string) bool {
// GetClusterConfig extracts cluster config from the configuration file // GetClusterConfig extracts cluster config from the configuration file
// and returns bytes of it // and returns bytes of it
func GetClusterConfig(configPath string) ([]byte, error) { func GetClusterConfig(configPath string) ([]byte, error) {
file, err := ioutil.ReadFile(configPath) file, err := os.ReadFile(configPath)
if err != nil { if err != nil {
logger.Error("error reading the configuration file: ", err) logger.Error("error reading the configuration file: ", err)
return nil, err return nil, err

View File

@ -5,10 +5,10 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "os"
crypto "github.com/libp2p/go-libp2p-core/crypto" crypto "github.com/libp2p/go-libp2p/core/crypto"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
) )
@ -77,7 +77,7 @@ func (ident *Identity) SaveJSON(path string) error {
return err return err
} }
return ioutil.WriteFile(path, bs, 0600) return os.WriteFile(path, bs, 0600)
} }
// ToJSON generates a human-friendly version of Identity. // ToJSON generates a human-friendly version of Identity.
@ -164,7 +164,7 @@ func (ident *Identity) Validate() error {
// LoadJSONFromFile reads an Identity file from disk and parses // LoadJSONFromFile reads an Identity file from disk and parses
// it and return Identity. // it and return Identity.
func (ident *Identity) LoadJSONFromFile(path string) error { func (ident *Identity) LoadJSONFromFile(path string) error {
file, err := ioutil.ReadFile(path) file, err := os.ReadFile(path)
if err != nil { if err != nil {
logger.Error("error reading the configuration file: ", err) logger.Error("error reading the configuration file: ", err)
return err return err

View File

@ -182,3 +182,39 @@ func DisplayJSON(cfg interface{}) ([]byte, error) {
} }
return DefaultJSONMarshal(data) return DefaultJSONMarshal(data)
} }
// Strings is a helper type that (un)marshals a single string to/from a single
// JSON string and a slice of strings to/from a JSON array of strings.
type Strings []string
// UnmarshalJSON conforms to the json.Unmarshaler interface.
func (o *Strings) UnmarshalJSON(data []byte) error {
if data[0] == '[' {
return json.Unmarshal(data, (*[]string)(o))
}
var value string
if err := json.Unmarshal(data, &value); err != nil {
return err
}
if len(value) == 0 {
*o = []string{}
} else {
*o = []string{value}
}
return nil
}
// MarshalJSON conforms to the json.Marshaler interface.
func (o Strings) MarshalJSON() ([]byte, error) {
switch len(o) {
case 0:
return json.Marshal(nil)
case 1:
return json.Marshal(o[0])
default:
return json.Marshal([]string(o))
}
}
var _ json.Unmarshaler = (*Strings)(nil)
var _ json.Marshaler = (*Strings)(nil)

View File

@ -3,7 +3,7 @@ package ipfscluster
import ( import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
"go.opencensus.io/trace" "go.opencensus.io/trace"
) )
@ -29,7 +29,7 @@ func (c *Cluster) ConnectGraph() (api.ConnectGraph, error) {
for _, member := range members { for _, member := range members {
// one of the entries is for itself, but that shouldn't hurt // one of the entries is for itself, but that shouldn't hurt
cg.ClusterTrustLinks[peer.Encode(member)] = c.consensus.IsTrustedPeer(ctx, member) cg.ClusterTrustLinks[member.String()] = c.consensus.IsTrustedPeer(ctx, member)
} }
peers := make([][]api.ID, len(members)) peers := make([][]api.ID, len(members))
@ -61,7 +61,7 @@ func (c *Cluster) ConnectGraph() (api.ConnectGraph, error) {
} }
for i, err := range errs { for i, err := range errs {
p := peer.Encode(members[i]) p := members[i].String()
cg.ClusterLinks[p] = make([]peer.ID, 0) cg.ClusterLinks[p] = make([]peer.ID, 0)
if err != nil { // Only setting cluster connections when no error occurs if err != nil { // Only setting cluster connections when no error occurs
logger.Debugf("RPC error reaching cluster peer %s: %s", p, err.Error()) logger.Debugf("RPC error reaching cluster peer %s: %s", p, err.Error())
@ -89,7 +89,7 @@ func (c *Cluster) recordClusterLinks(cg *api.ConnectGraph, p string, peers []api
logger.Debugf("Peer %s errored connecting to its peer %s", p, id.ID.Pretty()) logger.Debugf("Peer %s errored connecting to its peer %s", p, id.ID.Pretty())
continue continue
} }
if peer.Encode(id.ID) == p { if id.ID.String() == p {
selfConnection = true selfConnection = true
pID = id pID = id
} else { } else {
@ -106,8 +106,8 @@ func (c *Cluster) recordIPFSLinks(cg *api.ConnectGraph, pID api.ID) {
return return
} }
pid := peer.Encode(pID.ID) pid := pID.ID.String()
ipfsPid := peer.Encode(ipfsID) ipfsPid := ipfsID.String()
if _, ok := cg.IPFSLinks[pid]; ok { if _, ok := cg.IPFSLinks[pid]; ok {
logger.Warnf("ipfs id: %s already recorded, one ipfs daemon in use by multiple cluster peers", ipfsID.Pretty()) logger.Warnf("ipfs id: %s already recorded, one ipfs daemon in use by multiple cluster peers", ipfsID.Pretty())

View File

@ -9,7 +9,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/config" "github.com/ipfs-cluster/ipfs-cluster/config"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
) )

View File

@ -21,10 +21,10 @@ import (
crdt "github.com/ipfs/go-ds-crdt" crdt "github.com/ipfs/go-ds-crdt"
dshelp "github.com/ipfs/go-ipfs-ds-help" dshelp "github.com/ipfs/go-ipfs-ds-help"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
peerstore "github.com/libp2p/go-libp2p-core/peerstore" peerstore "github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p-core/routing" "github.com/libp2p/go-libp2p/core/routing"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"
multihash "github.com/multiformats/go-multihash" multihash "github.com/multiformats/go-multihash"

View File

@ -12,8 +12,8 @@ import (
ipns "github.com/ipfs/go-ipns" ipns "github.com/ipfs/go-ipns"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
peerstore "github.com/libp2p/go-libp2p-core/peerstore" peerstore "github.com/libp2p/go-libp2p/core/peerstore"
dht "github.com/libp2p/go-libp2p-kad-dht" dht "github.com/libp2p/go-libp2p-kad-dht"
dual "github.com/libp2p/go-libp2p-kad-dht/dual" dual "github.com/libp2p/go-libp2p-kad-dht/dual"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"

View File

@ -3,14 +3,14 @@ package raft
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"io/ioutil" "io"
"path/filepath" "path/filepath"
"time" "time"
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/config" "github.com/ipfs-cluster/ipfs-cluster/config"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
hraft "github.com/hashicorp/raft" hraft "github.com/hashicorp/raft"
"github.com/kelseyhightower/envconfig" "github.com/kelseyhightower/envconfig"
@ -288,7 +288,7 @@ func (cfg *Config) Default() error {
cfg.RaftConfig.LocalID = "will_be_set_automatically" cfg.RaftConfig.LocalID = "will_be_set_automatically"
// Set up logging // Set up logging
cfg.RaftConfig.LogOutput = ioutil.Discard cfg.RaftConfig.LogOutput = io.Discard
cfg.RaftConfig.Logger = &hcLogToLogger{} cfg.RaftConfig.Logger = &hcLogToLogger{}
return nil return nil
} }

View File

@ -17,10 +17,10 @@ import (
ds "github.com/ipfs/go-datastore" ds "github.com/ipfs/go-datastore"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
consensus "github.com/libp2p/go-libp2p-consensus" consensus "github.com/libp2p/go-libp2p-consensus"
host "github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
libp2praft "github.com/libp2p/go-libp2p-raft" libp2praft "github.com/libp2p/go-libp2p-raft"
host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p/core/peer"
"go.opencensus.io/tag" "go.opencensus.io/tag"
"go.opencensus.io/trace" "go.opencensus.io/trace"
@ -410,7 +410,7 @@ func (cc *Consensus) AddPeer(ctx context.Context, pid peer.ID) error {
} }
// Being here means we are the leader and can commit // Being here means we are the leader and can commit
cc.shutdownLock.RLock() // do not shutdown while committing cc.shutdownLock.RLock() // do not shutdown while committing
finalErr = cc.raft.AddPeer(ctx, peer.Encode(pid)) finalErr = cc.raft.AddPeer(ctx, pid.String())
cc.shutdownLock.RUnlock() cc.shutdownLock.RUnlock()
if finalErr != nil { if finalErr != nil {
@ -441,7 +441,7 @@ func (cc *Consensus) RmPeer(ctx context.Context, pid peer.ID) error {
} }
// Being here means we are the leader and can commit // Being here means we are the leader and can commit
cc.shutdownLock.RLock() // do not shutdown while committing cc.shutdownLock.RLock() // do not shutdown while committing
finalErr = cc.raft.RemovePeer(ctx, peer.Encode(pid)) finalErr = cc.raft.RemovePeer(ctx, pid.String())
cc.shutdownLock.RUnlock() cc.shutdownLock.RUnlock()
if finalErr != nil { if finalErr != nil {
time.Sleep(cc.config.CommitRetryDelay) time.Sleep(cc.config.CommitRetryDelay)

View File

@ -13,8 +13,8 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
peerstore "github.com/libp2p/go-libp2p-core/peerstore" peerstore "github.com/libp2p/go-libp2p/core/peerstore"
) )
func cleanRaft(idn int) { func cleanRaft(idn int) {

View File

@ -11,9 +11,9 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/state" "github.com/ipfs-cluster/ipfs-cluster/state"
host "github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-core/peer"
p2praft "github.com/libp2p/go-libp2p-raft" p2praft "github.com/libp2p/go-libp2p-raft"
host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p/core/peer"
hraft "github.com/hashicorp/raft" hraft "github.com/hashicorp/raft"
raftboltdb "github.com/hashicorp/raft-boltdb" raftboltdb "github.com/hashicorp/raft-boltdb"
@ -74,7 +74,7 @@ func newRaftWrapper(
raftW.host = host raftW.host = host
raftW.staging = staging raftW.staging = staging
// Set correct LocalID // Set correct LocalID
cfg.RaftConfig.LocalID = hraft.ServerID(peer.Encode(host.ID())) cfg.RaftConfig.LocalID = hraft.ServerID(host.ID().String())
df := cfg.GetDataFolder() df := cfg.GetDataFolder()
err := makeDataFolder(df) err := makeDataFolder(df)
@ -231,7 +231,7 @@ func makeServerConf(peers []peer.ID) hraft.Configuration {
// Servers are peers + self. We avoid duplicate entries below // Servers are peers + self. We avoid duplicate entries below
for _, pid := range peers { for _, pid := range peers {
p := peer.Encode(pid) p := pid.String()
_, ok := sm[p] _, ok := sm[p]
if !ok { // avoid dups if !ok { // avoid dups
sm[p] = struct{}{} sm[p] = struct{}{}
@ -273,7 +273,7 @@ func (rw *raftWrapper) WaitForVoter(ctx context.Context) error {
logger.Debug("waiting until we are promoted to a voter") logger.Debug("waiting until we are promoted to a voter")
pid := hraft.ServerID(peer.Encode(rw.host.ID())) pid := hraft.ServerID(rw.host.ID().String())
for { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():

139
go.mod
View File

@ -2,7 +2,7 @@ module github.com/ipfs-cluster/ipfs-cluster
require ( require (
contrib.go.opencensus.io/exporter/jaeger v0.2.1 contrib.go.opencensus.io/exporter/jaeger v0.2.1
contrib.go.opencensus.io/exporter/prometheus v0.4.1 contrib.go.opencensus.io/exporter/prometheus v0.4.2
github.com/blang/semver v3.5.1+incompatible github.com/blang/semver v3.5.1+incompatible
github.com/dgraph-io/badger v1.6.2 github.com/dgraph-io/badger v1.6.2
github.com/dustin/go-humanize v1.0.0 github.com/dustin/go-humanize v1.0.0
@ -10,88 +10,82 @@ require (
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/gorilla/handlers v1.5.1 github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-hclog v1.2.1 github.com/hashicorp/go-hclog v1.3.0
github.com/hashicorp/raft v1.1.1 github.com/hashicorp/raft v1.1.1
github.com/hashicorp/raft-boltdb v0.0.0-20190605210249-ef2e128ed477 github.com/hashicorp/raft-boltdb v0.0.0-20190605210249-ef2e128ed477
github.com/hsanjuan/ipfs-lite v1.4.1 github.com/hsanjuan/ipfs-lite v1.4.2
github.com/imdario/mergo v0.3.13 github.com/imdario/mergo v0.3.13
github.com/ipfs/go-block-format v0.0.3 github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-cid v0.2.0 github.com/ipfs/go-cid v0.3.2
github.com/ipfs/go-datastore v0.5.1 github.com/ipfs/go-datastore v0.6.0
github.com/ipfs/go-ds-badger v0.3.0 github.com/ipfs/go-ds-badger v0.3.0
github.com/ipfs/go-ds-crdt v0.3.6 github.com/ipfs/go-ds-crdt v0.3.7
github.com/ipfs/go-ds-leveldb v0.5.0 github.com/ipfs/go-ds-leveldb v0.5.0
github.com/ipfs/go-fs-lock v0.0.7 github.com/ipfs/go-fs-lock v0.0.7
github.com/ipfs/go-ipfs-api v0.3.0 github.com/ipfs/go-ipfs-api v0.3.0
github.com/ipfs/go-ipfs-chunker v0.0.5 github.com/ipfs/go-ipfs-chunker v0.0.5
github.com/ipfs/go-ipfs-cmds v0.6.0 github.com/ipfs/go-ipfs-cmds v0.6.0
github.com/ipfs/go-ipfs-config v0.19.0
github.com/ipfs/go-ipfs-ds-help v1.1.0 github.com/ipfs/go-ipfs-ds-help v1.1.0
github.com/ipfs/go-ipfs-files v0.1.1 github.com/ipfs/go-ipfs-files v0.1.1
github.com/ipfs/go-ipfs-pinner v0.2.1 github.com/ipfs/go-ipfs-pinner v0.2.1
github.com/ipfs/go-ipfs-posinfo v0.0.1 github.com/ipfs/go-ipfs-posinfo v0.0.1
github.com/ipfs/go-ipld-cbor v0.0.6 github.com/ipfs/go-ipld-cbor v0.0.6
github.com/ipfs/go-ipld-format v0.4.0 github.com/ipfs/go-ipld-format v0.4.0
github.com/ipfs/go-ipns v0.1.2 github.com/ipfs/go-ipns v0.2.0
github.com/ipfs/go-log/v2 v2.5.1 github.com/ipfs/go-log/v2 v2.5.1
github.com/ipfs/go-merkledag v0.6.0 github.com/ipfs/go-merkledag v0.7.0
github.com/ipfs/go-mfs v0.1.3-0.20210507195338-96fbfa122164 github.com/ipfs/go-mfs v0.1.3-0.20210507195338-96fbfa122164
github.com/ipfs/go-path v0.3.0 github.com/ipfs/go-path v0.3.0
github.com/ipfs/go-unixfs v0.4.0 github.com/ipfs/go-unixfs v0.4.0
github.com/ipld/go-car v0.4.0 github.com/ipld/go-car v0.5.0
github.com/kelseyhightower/envconfig v1.4.0 github.com/kelseyhightower/envconfig v1.4.0
github.com/kishansagathiya/go-dot v0.1.0 github.com/kishansagathiya/go-dot v0.1.0
github.com/lanzafame/go-libp2p-ocgorpc v0.1.1 github.com/lanzafame/go-libp2p-ocgorpc v0.1.1
github.com/libp2p/go-libp2p v0.20.1 github.com/libp2p/go-libp2p v0.22.0
github.com/libp2p/go-libp2p-consensus v0.0.1 github.com/libp2p/go-libp2p-consensus v0.0.1
github.com/libp2p/go-libp2p-core v0.16.1 github.com/libp2p/go-libp2p-gorpc v0.5.0
github.com/libp2p/go-libp2p-gorpc v0.4.0 github.com/libp2p/go-libp2p-gostream v0.5.0
github.com/libp2p/go-libp2p-gostream v0.4.0 github.com/libp2p/go-libp2p-http v0.4.0
github.com/libp2p/go-libp2p-http v0.3.0 github.com/libp2p/go-libp2p-kad-dht v0.18.0
github.com/libp2p/go-libp2p-kad-dht v0.16.0 github.com/libp2p/go-libp2p-pubsub v0.8.0
github.com/libp2p/go-libp2p-peerstore v0.6.0 github.com/libp2p/go-libp2p-raft v0.2.0
github.com/libp2p/go-libp2p-pubsub v0.7.0 github.com/libp2p/go-libp2p-record v0.2.0
github.com/libp2p/go-libp2p-raft v0.1.8
github.com/libp2p/go-libp2p-record v0.1.3
github.com/multiformats/go-multiaddr v0.6.0 github.com/multiformats/go-multiaddr v0.6.0
github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multiaddr-dns v0.3.1
github.com/multiformats/go-multicodec v0.5.0 github.com/multiformats/go-multicodec v0.6.0
github.com/multiformats/go-multihash v0.2.0 github.com/multiformats/go-multihash v0.2.1
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.2 github.com/prometheus/client_golang v1.13.0
github.com/rs/cors v1.8.2 github.com/rs/cors v1.8.2
github.com/syndtr/goleveldb v1.0.0 github.com/syndtr/goleveldb v1.0.0
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926
github.com/ugorji/go/codec v1.2.7 github.com/ugorji/go/codec v1.2.7
github.com/urfave/cli v1.22.9 github.com/urfave/cli v1.22.10
github.com/urfave/cli/v2 v2.10.2 github.com/urfave/cli/v2 v2.14.1
go.opencensus.io v0.23.0 go.opencensus.io v0.23.0
go.uber.org/multierr v1.8.0 go.uber.org/multierr v1.8.0
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
google.golang.org/protobuf v1.28.0 google.golang.org/protobuf v1.28.1
) )
require ( require (
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 // indirect github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect github.com/benbjohnson/clock v1.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/boltdb/bolt v1.3.1 // indirect github.com/boltdb/bolt v1.3.1 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.3 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cheekybits/genny v1.0.0 // indirect github.com/cheekybits/genny v1.0.0 // indirect
github.com/containerd/cgroups v1.0.3 // indirect github.com/containerd/cgroups v1.0.4 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect
github.com/cskr/pubsub v1.0.2 // indirect github.com/cskr/pubsub v1.0.2 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/dgraph-io/ristretto v0.0.2 // indirect github.com/dgraph-io/ristretto v0.0.2 // indirect
github.com/docker/go-units v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect github.com/elastic/gosigar v0.14.2 // indirect
@ -99,9 +93,11 @@ require (
github.com/felixge/httpsnoop v1.0.1 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/flynn/noise v1.0.0 // indirect github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-kit/log v0.2.0 // indirect github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
@ -118,14 +114,14 @@ require (
github.com/huin/goupnp v1.0.3 // indirect github.com/huin/goupnp v1.0.3 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-bitfield v1.0.0 // indirect github.com/ipfs/go-bitfield v1.0.0 // indirect
github.com/ipfs/go-bitswap v0.7.0 // indirect github.com/ipfs/go-bitswap v0.10.0 // indirect
github.com/ipfs/go-blockservice v0.3.0 // indirect github.com/ipfs/go-blockservice v0.4.0 // indirect
github.com/ipfs/go-cidutil v0.1.0 // indirect github.com/ipfs/go-cidutil v0.1.0 // indirect
github.com/ipfs/go-fetcher v1.6.1 // indirect github.com/ipfs/go-fetcher v1.6.1 // indirect
github.com/ipfs/go-ipfs-blockstore v1.2.0 // indirect github.com/ipfs/go-ipfs-blockstore v1.2.0 // indirect
github.com/ipfs/go-ipfs-delay v0.0.1 // indirect github.com/ipfs/go-ipfs-delay v0.0.1 // indirect
github.com/ipfs/go-ipfs-exchange-interface v0.1.0 // indirect github.com/ipfs/go-ipfs-exchange-interface v0.2.0 // indirect
github.com/ipfs/go-ipfs-exchange-offline v0.2.0 // indirect github.com/ipfs/go-ipfs-exchange-offline v0.3.0 // indirect
github.com/ipfs/go-ipfs-pq v0.0.2 // indirect github.com/ipfs/go-ipfs-pq v0.0.2 // indirect
github.com/ipfs/go-ipfs-provider v0.7.1 // indirect github.com/ipfs/go-ipfs-provider v0.7.1 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect github.com/ipfs/go-ipfs-util v0.0.2 // indirect
@ -134,42 +130,39 @@ require (
github.com/ipfs/go-metrics-interface v0.0.1 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect
github.com/ipfs/go-peertaskqueue v0.7.0 // indirect github.com/ipfs/go-peertaskqueue v0.7.0 // indirect
github.com/ipfs/go-verifcid v0.0.1 // indirect github.com/ipfs/go-verifcid v0.0.1 // indirect
github.com/ipfs/interface-go-ipfs-core v0.7.0 // indirect github.com/ipld/go-codec-dagpb v1.5.0 // indirect
github.com/ipld/go-codec-dagpb v1.3.2 // indirect github.com/ipld/go-ipld-prime v0.18.0 // indirect
github.com/ipld/go-ipld-prime v0.16.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect github.com/jbenet/goprocess v0.1.4 // indirect
github.com/klauspost/compress v1.15.1 // indirect github.com/klauspost/compress v1.15.1 // indirect
github.com/klauspost/cpuid/v2 v2.0.12 // indirect github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/koron/go-ssdp v0.0.2 // indirect github.com/koron/go-ssdp v0.0.3 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-eventbus v0.2.1 // indirect github.com/libp2p/go-flow-metrics v0.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.0.3 // indirect
github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect
github.com/libp2p/go-libp2p-connmgr v0.3.2-0.20220117144143-6ab8f6c9e796 // indirect github.com/libp2p/go-libp2p-core v0.20.0 // indirect
github.com/libp2p/go-libp2p-discovery v0.6.0 // indirect
github.com/libp2p/go-libp2p-kbucket v0.4.7 // indirect github.com/libp2p/go-libp2p-kbucket v0.4.7 // indirect
github.com/libp2p/go-libp2p-loggables v0.1.0 // indirect
github.com/libp2p/go-libp2p-resource-manager v0.3.0 // indirect
github.com/libp2p/go-libp2p-routing-helpers v0.2.3 // indirect github.com/libp2p/go-libp2p-routing-helpers v0.2.3 // indirect
github.com/libp2p/go-msgio v0.2.0 // indirect github.com/libp2p/go-msgio v0.2.0 // indirect
github.com/libp2p/go-nat v0.1.0 // indirect github.com/libp2p/go-nat v0.1.0 // indirect
github.com/libp2p/go-netroute v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.0 // indirect
github.com/libp2p/go-openssl v0.0.7 // indirect github.com/libp2p/go-openssl v0.1.0 // indirect
github.com/libp2p/go-reuseport v0.2.0 // indirect github.com/libp2p/go-reuseport v0.2.0 // indirect
github.com/libp2p/go-yamux/v3 v3.1.2 // indirect github.com/libp2p/go-yamux/v3 v3.1.2 // indirect
github.com/libp2p/zeroconf/v2 v2.1.1 // indirect github.com/libp2p/zeroconf/v2 v2.2.0 // indirect
github.com/lucas-clemente/quic-go v0.27.1 // indirect github.com/lucas-clemente/quic-go v0.28.1 // indirect
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
github.com/marten-seemann/qtls-go1-17 v0.1.1 // indirect github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect
github.com/marten-seemann/qtls-go1-18 v0.1.1 // indirect github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect
github.com/marten-seemann/qtls-go1-19 v0.1.0 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-pointer v0.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/miekg/dns v1.1.48 // indirect github.com/miekg/dns v1.1.50 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/sha256-simd v1.0.0 // indirect github.com/minio/sha256-simd v1.0.0 // indirect
@ -178,8 +171,8 @@ require (
github.com/multiformats/go-base32 v0.0.4 // indirect github.com/multiformats/go-base32 v0.0.4 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.0.3 // indirect github.com/multiformats/go-multibase v0.1.1 // indirect
github.com/multiformats/go-multistream v0.3.1 // indirect github.com/multiformats/go-multistream v0.3.3 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect github.com/multiformats/go-varint v0.0.6 // indirect
github.com/nxadm/tail v1.4.8 // indirect github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/ginkgo v1.16.5 // indirect
@ -188,11 +181,10 @@ require (
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect
github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.33.0 // indirect github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/statsd_exporter v0.21.0 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect
github.com/raulk/clock v1.1.0 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/raulk/go-watchdog v1.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect
@ -200,18 +192,19 @@ require (
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158 // indirect github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158 // indirect
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c // indirect github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c // indirect
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/atomic v1.9.0 // indirect go.opentelemetry.io/otel v1.7.0 // indirect
go.uber.org/zap v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/zap v1.22.0 // indirect
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220517181318-183a9ca12b87 // indirect golang.org/x/net v0.0.0-20220812174116-3211cb980234 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/tools v0.1.10 // indirect golang.org/x/tools v0.1.12 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/api v0.45.0 // indirect google.golang.org/api v0.45.0 // indirect
google.golang.org/genproto v0.0.0-20210510173355-fb37daa5cd7a // indirect google.golang.org/genproto v0.0.0-20210510173355-fb37daa5cd7a // indirect
@ -221,4 +214,4 @@ require (
lukechampine.com/blake3 v1.1.7 // indirect lukechampine.com/blake3 v1.1.7 // indirect
) )
go 1.18 go 1.19

419
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/state" "github.com/ipfs-cluster/ipfs-cluster/state"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -34,13 +34,13 @@ import (
ds "github.com/ipfs/go-datastore" ds "github.com/ipfs/go-datastore"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
crypto "github.com/libp2p/go-libp2p-core/crypto"
host "github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-core/peer"
peerstore "github.com/libp2p/go-libp2p-core/peerstore"
dht "github.com/libp2p/go-libp2p-kad-dht" dht "github.com/libp2p/go-libp2p-kad-dht"
dual "github.com/libp2p/go-libp2p-kad-dht/dual" dual "github.com/libp2p/go-libp2p-kad-dht/dual"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"
crypto "github.com/libp2p/go-libp2p/core/crypto"
host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p/core/peer"
peerstore "github.com/libp2p/go-libp2p/core/peerstore"
routedhost "github.com/libp2p/go-libp2p/p2p/host/routed" routedhost "github.com/libp2p/go-libp2p/p2p/host/routed"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@ -484,16 +484,16 @@ func runF(t *testing.T, clusters []*Cluster, f func(*testing.T, *Cluster)) {
wg.Wait() wg.Wait()
} }
////////////////////////////////////// // ////////////////////////////////////
// Delay and wait functions // Delay and wait functions
// //
// Delays are used in tests to wait for certain events to happen: // Delays are used in tests to wait for certain events to happen:
// * ttlDelay() waits for metrics to arrive. If you pin something // - ttlDelay() waits for metrics to arrive. If you pin something
// and your next operation depends on updated metrics, you need to wait // and your next operation depends on updated metrics, you need to wait
// * pinDelay() accounts for the time necessary to pin something and for the new // - pinDelay() accounts for the time necessary to pin something and for the new
// log entry to be visible in all cluster peers // log entry to be visible in all cluster peers
// * delay just sleeps a second or two. // - delay just sleeps a second or two.
// * waitForLeader functions make sure there is a raft leader, for example, // - waitForLeader functions make sure there is a raft leader, for example,
// after killing the leader. // after killing the leader.
// //
// The values for delays are a result of testing and adjusting so tests pass // The values for delays are a result of testing and adjusting so tests pass
@ -915,7 +915,7 @@ func TestClustersStatusAll(t *testing.T) {
} }
} }
pid := peer.Encode(c.host.ID()) pid := c.host.ID().String()
if info[pid].Status != api.TrackerStatusPinned { if info[pid].Status != api.TrackerStatusPinned {
t.Error("the hash should have been pinned") t.Error("the hash should have been pinned")
} }
@ -990,7 +990,7 @@ func TestClustersStatusAllWithErrors(t *testing.T) {
t.Error("bad number of peers in status") t.Error("bad number of peers in status")
} }
pid := peer.Encode(clusters[1].id) pid := clusters[1].id.String()
errst := stts.PeerMap[pid] errst := stts.PeerMap[pid]
if errst.Status != api.TrackerStatusClusterError { if errst.Status != api.TrackerStatusClusterError {
@ -1109,7 +1109,7 @@ func TestClustersRecover(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
pinfo, ok := ginfo.PeerMap[peer.Encode(clusters[j].host.ID())] pinfo, ok := ginfo.PeerMap[clusters[j].host.ID().String()]
if !ok { if !ok {
t.Fatal("should have info for this host") t.Fatal("should have info for this host")
} }
@ -1118,7 +1118,7 @@ func TestClustersRecover(t *testing.T) {
} }
for _, c := range clusters { for _, c := range clusters {
inf, ok := ginfo.PeerMap[peer.Encode(c.host.ID())] inf, ok := ginfo.PeerMap[c.host.ID().String()]
if !ok { if !ok {
t.Fatal("GlobalPinInfo should not be empty for this host") t.Fatal("GlobalPinInfo should not be empty for this host")
} }
@ -1143,7 +1143,7 @@ func TestClustersRecover(t *testing.T) {
} }
for _, c := range clusters { for _, c := range clusters {
inf, ok := ginfo.PeerMap[peer.Encode(c.host.ID())] inf, ok := ginfo.PeerMap[c.host.ID().String()]
if !ok { if !ok {
t.Fatal("GlobalPinInfo should have this cluster") t.Fatal("GlobalPinInfo should have this cluster")
} }
@ -1845,7 +1845,7 @@ func TestClustersRebalanceOnPeerDown(t *testing.T) {
// kill the local pinner // kill the local pinner
for _, c := range clusters { for _, c := range clusters {
clid := peer.Encode(c.id) clid := c.id.String()
if clid == localPinner { if clid == localPinner {
c.Shutdown(ctx) c.Shutdown(ctx)
} else if clid == remotePinner { } else if clid == remotePinner {
@ -1882,7 +1882,7 @@ func validateClusterGraph(t *testing.T, graph api.ConnectGraph, clusterIDs map[s
// Make lookup index for peers connected to id1 // Make lookup index for peers connected to id1
peerIndex := make(map[string]struct{}) peerIndex := make(map[string]struct{})
for _, p := range peers { for _, p := range peers {
peerIndex[peer.Encode(p)] = struct{}{} peerIndex[p.String()] = struct{}{}
} }
for id2 := range clusterIDs { for id2 := range clusterIDs {
if _, ok := peerIndex[id2]; id1 != id2 && !ok { if _, ok := peerIndex[id2]; id1 != id2 && !ok {
@ -1909,7 +1909,7 @@ func validateClusterGraph(t *testing.T, graph api.ConnectGraph, clusterIDs map[s
if len(graph.IPFSLinks) != 1 { if len(graph.IPFSLinks) != 1 {
t.Error("Expected exactly one ipfs peer for all cluster nodes, the mocked peer") t.Error("Expected exactly one ipfs peer for all cluster nodes, the mocked peer")
} }
links, ok := graph.IPFSLinks[peer.Encode(test.PeerID1)] links, ok := graph.IPFSLinks[test.PeerID1.String()]
if !ok { if !ok {
t.Error("Expected the mocked ipfs peer to be a node in the graph") t.Error("Expected the mocked ipfs peer to be a node in the graph")
} else { } else {
@ -1951,7 +1951,7 @@ func TestClustersGraphConnected(t *testing.T) {
clusterIDs := make(map[string]struct{}) clusterIDs := make(map[string]struct{})
for _, c := range clusters { for _, c := range clusters {
id := peer.Encode(c.ID(ctx).ID) id := c.ID(ctx).ID.String()
clusterIDs[id] = struct{}{} clusterIDs[id] = struct{}{}
} }
validateClusterGraph(t, graph, clusterIDs, nClusters) validateClusterGraph(t, graph, clusterIDs, nClusters)
@ -2000,7 +2000,7 @@ func TestClustersGraphUnhealthy(t *testing.T) {
if i == discon1 || i == discon2 { if i == discon1 || i == discon2 {
continue continue
} }
id := peer.Encode(c.ID(ctx).ID) id := c.ID(ctx).ID.String()
clusterIDs[id] = struct{}{} clusterIDs[id] = struct{}{}
} }
peerNum := nClusters peerNum := nClusters

View File

@ -8,7 +8,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
@ -25,8 +24,8 @@ import (
ipfspinner "github.com/ipfs/go-ipfs-pinner" ipfspinner "github.com/ipfs/go-ipfs-pinner"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
gopath "github.com/ipfs/go-path" gopath "github.com/ipfs/go-path"
peer "github.com/libp2p/go-libp2p-core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
peer "github.com/libp2p/go-libp2p/core/peer"
madns "github.com/multiformats/go-multiaddr-dns" madns "github.com/multiformats/go-multiaddr-dns"
manet "github.com/multiformats/go-multiaddr/net" manet "github.com/multiformats/go-multiaddr/net"
"github.com/multiformats/go-multicodec" "github.com/multiformats/go-multicodec"
@ -650,7 +649,7 @@ func checkResponse(path string, res *http.Response) ([]byte, error) {
return nil, nil return nil, nil
} }
body, err := ioutil.ReadAll(res.Body) body, err := io.ReadAll(res.Body)
res.Body.Close() res.Body.Close()
if err == nil { if err == nil {
var ipfsErr ipfsError var ipfsErr ipfsError
@ -679,7 +678,7 @@ func (ipfs *Connector) postCtx(ctx context.Context, path string, contentType str
} }
defer rdr.Close() defer rdr.Close()
body, err := ioutil.ReadAll(rdr) body, err := io.ReadAll(rdr)
if err != nil { if err != nil {
logger.Errorf("error reading response body: %s", err) logger.Errorf("error reading response body: %s", err)
return nil, err return nil, err

View File

@ -8,7 +8,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
// AlertChannelCap specifies how much buffer the alerts channel has. // AlertChannelCap specifies how much buffer the alerts channel has.

View File

@ -8,7 +8,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
func TestChecker_CheckPeers(t *testing.T) { func TestChecker_CheckPeers(t *testing.T) {

View File

@ -6,7 +6,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
// PeerMetrics maps a peer IDs to a metrics window. // PeerMetrics maps a peer IDs to a metrics window.

View File

@ -3,7 +3,7 @@ package metrics
import ( import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
// PeersetFilter removes all metrics not belonging to the given // PeersetFilter removes all metrics not belonging to the given

View File

@ -13,7 +13,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/monitor/metrics" "github.com/ipfs-cluster/ipfs-cluster/monitor/metrics"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"
gocodec "github.com/ugorji/go/codec" gocodec "github.com/ugorji/go/codec"

View File

@ -13,8 +13,8 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"
) )

View File

@ -12,8 +12,8 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/config" "github.com/ipfs-cluster/ipfs-cluster/config"
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@ -79,7 +79,7 @@ func peerManagerClusters(t *testing.T) ([]*Cluster, []*test.IpfsMock, host.Host)
func clusterAddr(c *Cluster) ma.Multiaddr { func clusterAddr(c *Cluster) ma.Multiaddr {
for _, a := range c.host.Addrs() { for _, a := range c.host.Addrs() {
if _, err := a.ValueForProtocol(ma.P_IP4); err == nil { if _, err := a.ValueForProtocol(ma.P_IP4); err == nil {
p := peer.Encode(c.id) p := c.id.String()
cAddr, _ := ma.NewMultiaddr(fmt.Sprintf("%s/p2p/%s", a, p)) cAddr, _ := ma.NewMultiaddr(fmt.Sprintf("%s/p2p/%s", a, p))
return cAddr return cAddr
} }

View File

@ -17,7 +17,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/observations" "github.com/ipfs-cluster/ipfs-cluster/observations"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
"go.opencensus.io/stats" "go.opencensus.io/stats"
"go.opencensus.io/trace" "go.opencensus.io/trace"

View File

@ -19,7 +19,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/state/dsstate" "github.com/ipfs-cluster/ipfs-cluster/state/dsstate"
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
var ( var (

View File

@ -15,7 +15,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/state" "github.com/ipfs-cluster/ipfs-cluster/state"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
"go.opencensus.io/trace" "go.opencensus.io/trace"

View File

@ -12,7 +12,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/state/dsstate" "github.com/ipfs-cluster/ipfs-cluster/state/dsstate"
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
) )

View File

@ -15,11 +15,11 @@ import (
"time" "time"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
host "github.com/libp2p/go-libp2p-core/host" host "github.com/libp2p/go-libp2p/core/host"
net "github.com/libp2p/go-libp2p-core/network" net "github.com/libp2p/go-libp2p/core/network"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
peerstore "github.com/libp2p/go-libp2p-core/peerstore" peerstore "github.com/libp2p/go-libp2p/core/peerstore"
pstoreutil "github.com/libp2p/go-libp2p-peerstore" pstoreutil "github.com/libp2p/go-libp2p/p2p/host/peerstore"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns" madns "github.com/multiformats/go-multiaddr-dns"
) )

View File

@ -9,7 +9,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/test" "github.com/ipfs-cluster/ipfs-cluster/test"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
) )
@ -28,7 +28,7 @@ func clean(pm *Manager) {
} }
func testAddr(loc string, pid peer.ID) ma.Multiaddr { func testAddr(loc string, pid peer.ID) ma.Multiaddr {
m, _ := ma.NewMultiaddr(loc + "/p2p/" + peer.Encode(pid)) m, _ := ma.NewMultiaddr(loc + "/p2p/" + pid.String())
return m return m
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/state" "github.com/ipfs-cluster/ipfs-cluster/state"
"github.com/ipfs-cluster/ipfs-cluster/version" "github.com/ipfs-cluster/ipfs-cluster/version"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
ocgorpc "github.com/lanzafame/go-libp2p-ocgorpc" ocgorpc "github.com/lanzafame/go-libp2p-ocgorpc"

View File

@ -9,7 +9,7 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
"github.com/ipfs-cluster/ipfs-cluster/datastore/inmem" "github.com/ipfs-cluster/ipfs-cluster/datastore/inmem"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
var testCid1, _ = api.DecodeCid("QmP63DkAFEnDYNjDYBpyNDfttu1fvUw99x1brscPzpqmmq") var testCid1, _ = api.DecodeCid("QmP63DkAFEnDYNjDYBpyNDfttu1fvUw99x1brscPzpqmmq")

View File

@ -2,7 +2,7 @@ package test
import ( import (
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
) )
// Common variables used all around tests. // Common variables used all around tests.

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
@ -395,7 +394,7 @@ func (m *IpfsMock) handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Stream-Error", err.Error()) w.Header().Set("X-Stream-Error", err.Error())
return return
} }
data, err := ioutil.ReadAll(part) data, err := io.ReadAll(part)
if err != nil { if err != nil {
w.Header().Set("X-Stream-Error", err.Error()) w.Header().Set("X-Stream-Error", err.Error())
return return

View File

@ -11,9 +11,9 @@ import (
"github.com/ipfs-cluster/ipfs-cluster/state" "github.com/ipfs-cluster/ipfs-cluster/state"
gopath "github.com/ipfs/go-path" gopath "github.com/ipfs/go-path"
host "github.com/libp2p/go-libp2p-core/host"
peer "github.com/libp2p/go-libp2p-core/peer"
rpc "github.com/libp2p/go-libp2p-gorpc" rpc "github.com/libp2p/go-libp2p-gorpc"
host "github.com/libp2p/go-libp2p/core/host"
peer "github.com/libp2p/go-libp2p/core/peer"
) )
var ( var (
@ -226,19 +226,19 @@ func (mock *mockCluster) ConnectGraph(ctx context.Context, in struct{}, out *api
*out = api.ConnectGraph{ *out = api.ConnectGraph{
ClusterID: PeerID1, ClusterID: PeerID1,
IPFSLinks: map[string][]peer.ID{ IPFSLinks: map[string][]peer.ID{
peer.Encode(PeerID4): {PeerID5, PeerID6}, PeerID4.String(): {PeerID5, PeerID6},
peer.Encode(PeerID5): {PeerID4, PeerID6}, PeerID5.String(): {PeerID4, PeerID6},
peer.Encode(PeerID6): {PeerID4, PeerID5}, PeerID6.String(): {PeerID4, PeerID5},
}, },
ClusterLinks: map[string][]peer.ID{ ClusterLinks: map[string][]peer.ID{
peer.Encode(PeerID1): {PeerID2, PeerID3}, PeerID1.String(): {PeerID2, PeerID3},
peer.Encode(PeerID2): {PeerID1, PeerID3}, PeerID2.String(): {PeerID1, PeerID3},
peer.Encode(PeerID3): {PeerID1, PeerID2}, PeerID3.String(): {PeerID1, PeerID2},
}, },
ClustertoIPFS: map[string]peer.ID{ ClustertoIPFS: map[string]peer.ID{
peer.Encode(PeerID1): PeerID4, PeerID1.String(): PeerID4,
peer.Encode(PeerID2): PeerID5, PeerID2.String(): PeerID5,
peer.Encode(PeerID3): PeerID6, PeerID3.String(): PeerID6,
}, },
} }
return nil return nil
@ -248,7 +248,7 @@ func (mock *mockCluster) StatusAll(ctx context.Context, in <-chan api.TrackerSta
defer close(out) defer close(out)
filter := <-in filter := <-in
pid := peer.Encode(PeerID1) pid := PeerID1.String()
gPinInfos := []api.GlobalPinInfo{ gPinInfos := []api.GlobalPinInfo{
{ {
Cid: Cid1, Cid: Cid1,
@ -323,7 +323,7 @@ func (mock *mockCluster) Status(ctx context.Context, in api.Cid, out *api.Global
}, },
PeerMap: map[string]api.PinInfoShort{ PeerMap: map[string]api.PinInfoShort{
peer.Encode(PeerID1): { PeerID1.String(): {
PeerName: PeerName3, PeerName: PeerName3,
IPFS: PeerID3, IPFS: PeerID3,
IPFSAddresses: []api.Multiaddr{ma}, IPFSAddresses: []api.Multiaddr{ma},
@ -371,7 +371,7 @@ func (mock *mockCluster) RepoGC(ctx context.Context, in struct{}, out *api.Globa
_ = mock.RepoGCLocal(ctx, struct{}{}, &localrepoGC) _ = mock.RepoGCLocal(ctx, struct{}{}, &localrepoGC)
*out = api.GlobalRepoGC{ *out = api.GlobalRepoGC{
PeerMap: map[string]api.RepoGC{ PeerMap: map[string]api.RepoGC{
peer.Encode(PeerID1): localrepoGC, PeerID1.String(): localrepoGC,
}, },
} }
return nil return nil

View File

@ -10,7 +10,7 @@ import (
blake2b "golang.org/x/crypto/blake2b" blake2b "golang.org/x/crypto/blake2b"
"github.com/ipfs-cluster/ipfs-cluster/api" "github.com/ipfs-cluster/ipfs-cluster/api"
peer "github.com/libp2p/go-libp2p-core/peer" peer "github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns" madns "github.com/multiformats/go-multiaddr-dns"
) )

View File

@ -3,7 +3,7 @@ package version
import ( import (
semver "github.com/blang/semver" semver "github.com/blang/semver"
protocol "github.com/libp2p/go-libp2p-core/protocol" protocol "github.com/libp2p/go-libp2p/core/protocol"
) )
// Version is the current cluster version. // Version is the current cluster version.