Skip to content

Commit

Permalink
feat: upgrade to go-libp2p-kad-dht@v0.16.0 (#9005)
Browse files Browse the repository at this point in the history
* feat: upgrade to go-libp2p-kad-dht@v0.16.0

* rename "cid format --codec" to "cid format --mc"

* refactor(test): from --codec to --mc

Co-authored-by: Marcin Rataj <lidel@lidel.org>
(cherry picked from commit 8d7ed00)
  • Loading branch information
guseggert committed Jun 8, 2022
1 parent eb8598e commit 10342b7
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 88 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ Below is an outline of all that is in this release, so you get a sense of all th
- Now lists codecs from [go-multicodec](https://github.com/multiformats/go-multicodec) library.
- `ipfs cid codecs --supported` can be passed to only show codecs supported in various go-ipfs commands.

#### `ipfs cid format` command
- `--codec` was removed and replaced with `--mc` to ensure existing users are aware of the following changes:
- `--mc protobuf` now correctly points to code `0x50` (was `0x70`, which is `dab-pg`)
- `--mc cbor` now correctly points to code `0x51` (was `0x71`, which is `dag-cbor`)

#### `Swarm` configuration
- Daemon will refuse to start if long-deprecated RelayV1 config key `Swarm.EnableAutoRelay` or `Swarm.DisableRelay` is set to `true`.
- If `Swarm.Transports.Network.Relay` is disabled, then `Swarm.RelayService` and `Swarm.RelayClient` are also disabled (unless they have been explicitly enabled).
Expand Down
22 changes: 12 additions & 10 deletions core/commands/cid.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
cidutil "github.com/ipfs/go-cidutil"
cmds "github.com/ipfs/go-ipfs-cmds"
verifcid "github.com/ipfs/go-verifcid"
"github.com/ipld/go-ipld-prime/multicodec"
ipldmulticodec "github.com/ipld/go-ipld-prime/multicodec"
mbase "github.com/multiformats/go-multibase"
"github.com/multiformats/go-multicodec"
mc "github.com/multiformats/go-multicodec"
mhash "github.com/multiformats/go-multihash"
)
Expand All @@ -34,7 +35,7 @@ var CidCmd = &cmds.Command{
const (
cidFormatOptionName = "f"
cidVerisonOptionName = "v"
cidCodecOptionName = "codec"
cidCodecOptionName = "mc"
cidMultibaseOptionName = "b"
)

Expand All @@ -53,7 +54,7 @@ The optional format string is a printf style format string:
Options: []cmds.Option{
cmds.StringOption(cidFormatOptionName, "Printf style format string.").WithDefault("%s"),
cmds.StringOption(cidVerisonOptionName, "CID version to convert to."),
cmds.StringOption(cidCodecOptionName, "CID codec to convert to."),
cmds.StringOption(cidCodecOptionName, "CID multicodec to convert to."),
cmds.StringOption(cidMultibaseOptionName, "Multibase to display CID in."),
},
Run: func(req *cmds.Request, resp cmds.ResponseEmitter, env cmds.Environment) error {
Expand All @@ -70,11 +71,12 @@ The optional format string is a printf style format string:
opts.fmtStr = fmtStr

if codecStr != "" {
codec, ok := cid.Codecs[codecStr]
if !ok {
return fmt.Errorf("unknown IPLD codec: %q", codecStr)
var codec multicodec.Code
err := codec.Set(codecStr)
if err != nil {
return err
}
opts.newCodec = codec
opts.newCodec = uint64(codec)
} // otherwise, leave it as 0 (not a valid IPLD codec)

switch verStr {
Expand Down Expand Up @@ -311,7 +313,7 @@ const (

var codecsCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "List available CID codecs.",
Tagline: "List available CID multicodecs.",
ShortDescription: `
'ipfs cid codecs' relies on https://github.com/multiformats/go-multicodec
`,
Expand All @@ -324,10 +326,10 @@ var codecsCmd = &cmds.Command{
listSupported, _ := req.Options[codecsSupportedOptionName].(bool)
supportedCodecs := make(map[uint64]struct{})
if listSupported {
for _, code := range multicodec.ListEncoders() {
for _, code := range ipldmulticodec.ListEncoders() {
supportedCodecs[code] = struct{}{}
}
for _, code := range multicodec.ListDecoders() {
for _, code := range ipldmulticodec.ListDecoders() {
supportedCodecs[code] = struct{}{}
}
// add libp2p-key
Expand Down
50 changes: 25 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require (
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc
contrib.go.opencensus.io/exporter/prometheus v0.4.0
github.com/blang/semver/v4 v4.0.0
github.com/cenkalti/backoff/v4 v4.1.2
github.com/cenkalti/backoff/v4 v4.1.3
github.com/ceramicnetwork/go-dag-jose v0.1.0
github.com/cespare/xxhash v1.1.0
github.com/cheggaaa/pb v1.0.29
Expand All @@ -18,8 +18,8 @@ require (
github.com/ipfs/go-bitswap v0.6.0
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-blockservice v0.3.0
github.com/ipfs/go-cid v0.1.0
github.com/ipfs/go-cidutil v0.0.2
github.com/ipfs/go-cid v0.2.0
github.com/ipfs/go-cidutil v0.1.0
github.com/ipfs/go-datastore v0.5.1
github.com/ipfs/go-detect-race v0.0.1
github.com/ipfs/go-ds-badger v0.3.0
Expand Down Expand Up @@ -72,7 +72,7 @@ require (
github.com/libp2p/go-libp2p-core v0.15.1
github.com/libp2p/go-libp2p-discovery v0.6.0
github.com/libp2p/go-libp2p-http v0.2.1
github.com/libp2p/go-libp2p-kad-dht v0.15.0
github.com/libp2p/go-libp2p-kad-dht v0.16.0
github.com/libp2p/go-libp2p-kbucket v0.4.7
github.com/libp2p/go-libp2p-loggables v0.1.0
github.com/libp2p/go-libp2p-mplex v0.7.0
Expand Down Expand Up @@ -108,21 +108,21 @@ require (
github.com/whyrusleeping/go-sysinfo v0.0.0-20190219211824-4a357d4b90b1
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7
go.opencensus.io v0.23.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.31.0
go.opentelemetry.io/otel v1.6.3
go.opentelemetry.io/otel/exporters/jaeger v1.6.3
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.6.3
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.6.3
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.6.3
go.opentelemetry.io/otel/exporters/zipkin v1.6.3
go.opentelemetry.io/otel/sdk v1.6.3
go.opentelemetry.io/otel/trace v1.6.3
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0
go.opentelemetry.io/otel v1.7.0
go.opentelemetry.io/otel/exporters/jaeger v1.7.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.7.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.7.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.7.0
go.opentelemetry.io/otel/exporters/zipkin v1.7.0
go.opentelemetry.io/otel/sdk v1.7.0
go.opentelemetry.io/otel/trace v1.7.0
go.uber.org/dig v1.14.0
go.uber.org/fx v1.16.0
go.uber.org/zap v1.21.0
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e
)

require (
Expand All @@ -137,7 +137,7 @@ require (
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect
github.com/alexbrainman/goissue34681 v0.0.0-20191006012335-3fc7a47baff5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
Expand All @@ -150,7 +150,7 @@ require (
github.com/dgraph-io/ristretto v0.0.2 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/go-kit/log v0.2.0 // indirect
Expand All @@ -168,7 +168,7 @@ require (
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
Expand All @@ -192,7 +192,7 @@ require (
github.com/libp2p/go-libp2p-nat v0.1.0 // indirect
github.com/libp2p/go-libp2p-pnet v0.2.0 // indirect
github.com/libp2p/go-libp2p-transport-upgrader v0.7.1 // indirect
github.com/libp2p/go-libp2p-xor v0.0.0-20210714161855-5c005aca55db // indirect
github.com/libp2p/go-libp2p-xor v0.1.0 // indirect
github.com/libp2p/go-mplex v0.7.0 // indirect
github.com/libp2p/go-msgio v0.2.0 // indirect
github.com/libp2p/go-nat v0.1.0 // indirect
Expand Down Expand Up @@ -248,24 +248,24 @@ require (
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
github.com/whyrusleeping/mdns v0.0.0-20190826153040-b9b60ed33aa9 // indirect
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.6.3 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.6.3 // indirect
go.opentelemetry.io/otel/metric v0.28.0 // indirect
go.opentelemetry.io/proto/otlp v0.15.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.7.0 // indirect
go.opentelemetry.io/otel/metric v0.30.0 // indirect
go.opentelemetry.io/proto/otlp v0.16.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
golang.org/x/exp v0.0.0-20210615023648-acb5c1269671 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 // indirect
golang.org/x/net v0.0.0-20220517181318-183a9ca12b87 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/grpc v1.46.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
Expand Down
Loading

0 comments on commit 10342b7

Please sign in to comment.