Skip to content

Commit

Permalink
code review improvements
Browse files Browse the repository at this point in the history
- change core.IpfsNode as first arg
- check keylookup err to propagate validation errors from lower levels
  • Loading branch information
keremgocen committed Apr 27, 2017
1 parent 39ece86 commit f93e8c5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/commands/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

cmds "github.com/ipfs/go-ipfs/commands"
core "github.com/ipfs/go-ipfs/core"
keystore "github.com/ipfs/go-ipfs/keystore"
path "github.com/ipfs/go-ipfs/path"

crypto "gx/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY/go-libp2p-crypto"
Expand Down Expand Up @@ -121,7 +122,7 @@ Alternatively, publish an <ipfs-path> using a valid PeerID(as listed by 'ipfs ke
}

kname, _, _ := req.Option("key").String()
k, err := keylookup(kname, n)
k, err := keylookup(n, kname)
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
Expand Down Expand Up @@ -182,13 +183,17 @@ func publish(ctx context.Context, n *core.IpfsNode, k crypto.PrivKey, ref path.P
}, nil
}

func keylookup(k string, n *core.IpfsNode) (crypto.PrivKey, error) {
func keylookup(n *core.IpfsNode, k string) (crypto.PrivKey, error) {

res, err := n.GetKey(k)
if res != nil {
return res, nil
}

if err != nil && err != keystore.ErrNoSuchKey {
return nil, err
}

keys, err := n.Repo.Keystore().List()
if err != nil {
return nil, err
Expand Down

1 comment on commit f93e8c5

@GitCop
Copy link

@GitCop GitCop commented on f93e8c5 Apr 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

Please sign in to comment.