提交 6f6d79d6 作者: Brian Tiger Chow

refactor(identify) extract proto encoding

上级 1386205f
......@@ -34,17 +34,14 @@ var ErrUnsupportedKeyType = errors.New("unsupported key type")
// Performs initial communication with this peer to share node ID's and
// initiate communication. (secureIn, secureOut, error)
func Handshake(self, remote *peer.Peer, in <-chan []byte, out chan<- []byte) (<-chan []byte, chan<- []byte, error) {
h, err := genRandHello(self)
if err != nil {
return nil, nil, err
}
encoded, err := proto.Marshal(h)
encodedHello, err := encodedProtoHello(self)
if err != nil {
return nil, nil, err
}
out <- encoded
// TODO(brian): select on |ctx|
out <- encodedHello
// Parse their Hello packet and generate an Exchange packet.
// Exchange = (EphemeralPubKey, Signature)
......@@ -322,3 +319,12 @@ func genRandHello(self *peer.Peer) (*Hello, error) {
hello.Hashes = &SupportedHashes
return hello, nil
}
func encodedProtoHello(self *peer.Peer) ([]byte, error) {
h, err := genRandHello(self)
if err != nil {
return nil, err
}
return proto.Marshal(h)
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论