提交 b88ee287 作者: Siraj Ravel

golint cleanup

上级 c370fc50
...@@ -68,7 +68,7 @@ func initCmd(c *commander.Command, inp []string) error { ...@@ -68,7 +68,7 @@ func initCmd(c *commander.Command, inp []string) error {
} }
cfg.Identity.PrivKey = base64.StdEncoding.EncodeToString(skbytes) cfg.Identity.PrivKey = base64.StdEncoding.EncodeToString(skbytes)
id, err := identify.IdFromPubKey(pk) id, err := identify.IDFromPubKey(pk)
if err != nil { if err != nil {
return err return err
} }
......
// The identify package handles how peers identify with eachother upon // Package identify handles how peers identify with eachother upon
// connection to the network // connection to the network
package identify package identify
...@@ -31,7 +31,7 @@ var SupportedHashes = "SHA256,SHA512,SHA1" ...@@ -31,7 +31,7 @@ var SupportedHashes = "SHA256,SHA512,SHA1"
// ErrUnsupportedKeyType is returned when a private key cast/type switch fails. // ErrUnsupportedKeyType is returned when a private key cast/type switch fails.
var ErrUnsupportedKeyType = errors.New("unsupported key type") var ErrUnsupportedKeyType = errors.New("unsupported key type")
// Perform initial communication with this peer to share node ID's and // Performs initial communication with this peer to share node ID's and
// initiate communication. (secureIn, secureOut, error) // initiate communication. (secureIn, secureOut, error)
func Handshake(self, remote *peer.Peer, in, out chan []byte) (chan []byte, chan []byte, error) { func Handshake(self, remote *peer.Peer, in, out chan []byte) (chan []byte, chan []byte, error) {
// Generate and send Hello packet. // Generate and send Hello packet.
...@@ -74,7 +74,7 @@ func Handshake(self, remote *peer.Peer, in, out chan []byte) (chan []byte, chan ...@@ -74,7 +74,7 @@ func Handshake(self, remote *peer.Peer, in, out chan []byte) (chan []byte, chan
return nil, nil, err return nil, nil, err
} }
remote.ID, err = IdFromPubKey(remote.PubKey) remote.ID, err = IDFromPubKey(remote.PubKey)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
...@@ -238,8 +238,8 @@ func secureOutProxy(out, secureOut chan []byte, hashType string, mIV, mCKey, mMK ...@@ -238,8 +238,8 @@ func secureOutProxy(out, secureOut chan []byte, hashType string, mIV, mCKey, mMK
out <- buff out <- buff
} }
} }
// IDFromPubKey returns Nodes ID given its public key
func IdFromPubKey(pk ci.PubKey) (peer.ID, error) { func IDFromPubKey(pk ci.PubKey) (peer.ID, error) {
b, err := pk.Bytes() b, err := pk.Bytes()
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -20,7 +20,7 @@ func TestHandshake(t *testing.T) { ...@@ -20,7 +20,7 @@ func TestHandshake(t *testing.T) {
cha := make(chan []byte, 5) cha := make(chan []byte, 5)
chb := make(chan []byte, 5) chb := make(chan []byte, 5)
ida, err := IdFromPubKey(pka) ida, err := IDFromPubKey(pka)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -30,7 +30,7 @@ func TestHandshake(t *testing.T) { ...@@ -30,7 +30,7 @@ func TestHandshake(t *testing.T) {
PrivKey: ska, PrivKey: ska,
} }
idb, err := IdFromPubKey(pkb) idb, err := IDFromPubKey(pkb)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
......
...@@ -35,7 +35,7 @@ func setupDHTS(n int, t *testing.T) ([]*ma.Multiaddr, []*peer.Peer, []*IpfsDHT) ...@@ -35,7 +35,7 @@ func setupDHTS(n int, t *testing.T) ([]*ma.Multiaddr, []*peer.Peer, []*IpfsDHT)
} }
p.PubKey = pk p.PubKey = pk
p.PrivKey = sk p.PrivKey = sk
id, err := identify.IdFromPubKey(pk) id, err := identify.IDFromPubKey(pk)
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -67,7 +67,7 @@ func makePeer(addr *ma.Multiaddr) *peer.Peer { ...@@ -67,7 +67,7 @@ func makePeer(addr *ma.Multiaddr) *peer.Peer {
} }
p.PrivKey = sk p.PrivKey = sk
p.PubKey = pk p.PubKey = pk
id, err := identify.IdFromPubKey(pk) id, err := identify.IDFromPubKey(pk)
if err != nil { if err != nil {
panic(err) panic(err)
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论