From 4394dca7826646f5265fa5a15ab43c6f9062c3ea Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 14 Dec 2019 19:48:31 +0100 Subject: [PATCH] fix: move away from deprecated peer ID functions --- core/commands/bitswap.go | 4 ++-- core/commands/dht.go | 4 ++-- core/commands/id.go | 2 +- core/commands/name/ipnsps.go | 4 ++-- core/commands/ping.go | 2 +- core/commands/stat.go | 2 +- core/node/groups.go | 2 +- namesys/namesys.go | 2 +- namesys/routing.go | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/commands/bitswap.go b/core/commands/bitswap.go index 7f7b2e83481..095d7d5b53d 100644 --- a/core/commands/bitswap.go +++ b/core/commands/bitswap.go @@ -60,7 +60,7 @@ Print out all blocks currently on the bitswap wantlist for the local peer.`, pstr, found := req.Options[peerOptionName].(string) if found { - pid, err := peer.IDB58Decode(pstr) + pid, err := peer.Decode(pstr) if err != nil { return err } @@ -195,7 +195,7 @@ prints the ledger associated with a given peer. return e.TypeErr(bs, nd.Exchange) } - partner, err := peer.IDB58Decode(req.Arguments[0]) + partner, err := peer.Decode(req.Arguments[0]) if err != nil { return err } diff --git a/core/commands/dht.go b/core/commands/dht.go index a0b6380fd0a..3b1d2b15b27 100644 --- a/core/commands/dht.go +++ b/core/commands/dht.go @@ -68,7 +68,7 @@ var queryDhtCmd = &cmds.Command{ return ErrNotDHT } - id, err := peer.IDB58Decode(req.Arguments[0]) + id, err := peer.Decode(req.Arguments[0]) if err != nil { return cmds.ClientError("invalid peer ID") } @@ -370,7 +370,7 @@ var findPeerDhtCmd = &cmds.Command{ return ErrNotOnline } - pid, err := peer.IDB58Decode(req.Arguments[0]) + pid, err := peer.Decode(req.Arguments[0]) if err != nil { return err } diff --git a/core/commands/id.go b/core/commands/id.go index d911b23ef81..44d1980aa6e 100644 --- a/core/commands/id.go +++ b/core/commands/id.go @@ -75,7 +75,7 @@ EXAMPLE: var id peer.ID if len(req.Arguments) > 0 { var err error - id, err = peer.IDB58Decode(req.Arguments[0]) + id, err = peer.Decode(req.Arguments[0]) if err != nil { return fmt.Errorf("invalid peer id") } diff --git a/core/commands/name/ipnsps.go b/core/commands/name/ipnsps.go index 07063bff38a..3511bed4aa7 100644 --- a/core/commands/name/ipnsps.go +++ b/core/commands/name/ipnsps.go @@ -93,7 +93,7 @@ var ipnspsSubsCmd = &cmds.Command{ log.Errorf("ipns key not a valid peer ID: %s", err) continue } - paths = append(paths, "/ipns/"+peer.IDB58Encode(pid)) + paths = append(paths, "/ipns/"+peer.Encode(pid)) } return cmds.EmitOnce(res, &stringList{paths}) @@ -120,7 +120,7 @@ var ipnspsCancelCmd = &cmds.Command{ name := req.Arguments[0] name = strings.TrimPrefix(name, "/ipns/") - pid, err := peer.IDB58Decode(name) + pid, err := peer.Decode(name) if err != nil { return cmds.Errorf(cmds.ErrClient, err.Error()) } diff --git a/core/commands/ping.go b/core/commands/ping.go index 89352ad1b34..3c48018a7a7 100644 --- a/core/commands/ping.go +++ b/core/commands/ping.go @@ -217,6 +217,6 @@ func ParsePeerParam(text string) (ma.Multiaddr, peer.ID, error) { return transport, id, nil } // Raw peer ID - p, err := peer.IDB58Decode(text) + p, err := peer.Decode(text) return nil, p, err } diff --git a/core/commands/stat.go b/core/commands/stat.go index 21098090f4a..7da0b7ddd56 100644 --- a/core/commands/stat.go +++ b/core/commands/stat.go @@ -109,7 +109,7 @@ Example: var pid peer.ID if pfound { - checkpid, err := peer.IDB58Decode(pstr) + checkpid, err := peer.Decode(pstr) if err != nil { return err } diff --git a/core/node/groups.go b/core/node/groups.go index b567f34fac8..b2dbce27d58 100644 --- a/core/node/groups.go +++ b/core/node/groups.go @@ -154,7 +154,7 @@ func Identity(cfg *config.Config) fx.Option { return fx.Error(errors.New("no peer ID in config! (was 'ipfs init' run?)")) } - id, err := peer.IDB58Decode(cid) + id, err := peer.Decode(cid) if err != nil { return fx.Error(fmt.Errorf("peer ID invalid: %s", err)) } diff --git a/namesys/namesys.go b/namesys/namesys.go index 7ae93e3e269..079eecccc03 100644 --- a/namesys/namesys.go +++ b/namesys/namesys.go @@ -189,6 +189,6 @@ func (ns *mpns) PublishWithEOL(ctx context.Context, name ci.PrivKey, value path. if ttEol := time.Until(eol); ttEol < ttl { ttl = ttEol } - ns.cacheSet(peer.IDB58Encode(id), value, ttl) + ns.cacheSet(peer.Encode(id), value, ttl) return nil } diff --git a/namesys/routing.go b/namesys/routing.go index 94c12a72617..c2d0d0252d4 100644 --- a/namesys/routing.go +++ b/namesys/routing.go @@ -59,7 +59,7 @@ func (r *IpnsResolver) resolveOnceAsync(ctx context.Context, name string, option } name = strings.TrimPrefix(name, "/ipns/") - pid, err := peer.IDB58Decode(name) + pid, err := peer.Decode(name) if err != nil { log.Debugf("RoutingResolver: could not convert public key hash %s to peer ID: %s\n", name, err) out <- onceResult{err: err}