Skip to content

Commit

Permalink
fix for #381
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping authored and Brian Tiger Chow committed Dec 1, 2014
1 parent 962326b commit 2f0d3ff
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions core/commands/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ if no peer is specified, prints out local peers info.

p, err := node.Routing.FindPeer(ctx, id)
if err == kb.ErrLookupFailure {
log.Error("what? no.")
return nil, errors.New(offlineIdErrorMessage)
}
if err != nil {
Expand Down Expand Up @@ -93,15 +94,13 @@ func printPeer(p peer.Peer) (interface{}, error) {
info := new(IdOutput)

info.ID = p.ID().String()
if p.PubKey() == nil {
return nil, errors.New(`peer publickey not populated on offline runs,
please run the daemon to use ipfs id!`)
}
pkb, err := p.PubKey().Bytes()
if err != nil {
return nil, err
if p.PubKey() != nil {
pkb, err := p.PubKey().Bytes()
if err != nil {
return nil, err
}
info.PublicKey = base64.StdEncoding.EncodeToString(pkb)
}
info.PublicKey = base64.StdEncoding.EncodeToString(pkb)
for _, a := range p.Addresses() {
info.Addresses = append(info.Addresses, a.String())
}
Expand Down

0 comments on commit 2f0d3ff

Please sign in to comment.