Commit 3f63e50c authored by Brian Tiger Chow's avatar Brian Tiger Chow

fix(peer): use error-checking multiaddr method

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 9b73003b
......@@ -149,8 +149,12 @@ func splitAddresses(addrs []string) (maddrs []ma.Multiaddr, pids []peer.ID, err
if err != nil {
return nil, nil, cmds.ClientError("invalid peer address: " + err.Error())
}
id, err := peer.DecodePrettyID(path.Base(addr))
if err != nil {
return nil, nil, err
}
pids[i] = id
maddrs[i] = a
pids[i] = peer.DecodePrettyID(path.Base(addr))
}
return
}
......
......@@ -265,7 +265,11 @@ func initConnections(ctx context.Context, cfg *config.Config, pstore peer.Peerst
}
// setup peer
npeer, err := pstore.Get(peer.DecodePrettyID(p.PeerID))
id, err := peer.DecodePrettyID(p.PeerID)
if err != nil {
// return err
}
npeer, err := pstore.Get(id)
if err != nil {
log.Criticalf("Bootstrapping error: %v", err)
continue
......
......@@ -37,8 +37,12 @@ func (id ID) Pretty() string {
}
// DecodePrettyID returns a b58-encoded string of the ID
func DecodePrettyID(s string) ID {
return b58.Decode(s)
func DecodePrettyID(s string) (ID, error) {
m, err := mh.FromB58String(s)
if err != nil {
return nil, err
}
return ID(m), err
}
// IDFromPubKey retrieves a Public Key from the peer given by pk
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment