fix protocol to accomodate privkey

This commit is contained in:
zelig 2015-01-18 09:44:49 +00:00 committed by Felix Lange
parent 88167f39a6
commit d227f6184e
2 changed files with 14 additions and 1 deletions

View File

@ -64,6 +64,10 @@ func (h *handshake) Pubkey() []byte {
return h.NodeID
}
func (h *handshake) PrivKey() []byte {
return nil
}
// Cap is the structure of a peer capability.
type Cap struct {
Name string

View File

@ -11,7 +11,7 @@ import (
)
type peerId struct {
pubkey []byte
privKey, pubkey []byte
}
func (self *peerId) String() string {
@ -27,6 +27,15 @@ func (self *peerId) Pubkey() (pubkey []byte) {
return
}
func (self *peerId) PrivKey() (privKey []byte) {
privKey = self.privKey
if len(privKey) == 0 {
privKey = crypto.GenerateNewKeyPair().PublicKey
self.privKey = privKey
}
return
}
func newTestPeer() (peer *Peer) {
peer = NewPeer(&peerId{}, []Cap{})
peer.pubkeyHook = func(*peerAddr) error { return nil }