Skip to content

Commit d227f61

Browse files
zeligfjl
authored andcommitted
fix protocol to accomodate privkey
1 parent 88167f3 commit d227f61

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎p2p/protocol.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func (h *handshake) Pubkey() []byte {
6464
return h.NodeID
6565
}
6666

67+
func (h *handshake) PrivKey() []byte {
68+
return nil
69+
}
70+
6771
// Cap is the structure of a peer capability.
6872
type Cap struct {
6973
Name string

‎p2p/protocol_test.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
type peerId struct {
14-
pubkey []byte
14+
privKey, pubkey []byte
1515
}
1616

1717
func (self *peerId) String() string {
@@ -27,6 +27,15 @@ func (self *peerId) Pubkey() (pubkey []byte) {
2727
return
2828
}
2929

30+
func (self *peerId) PrivKey() (privKey []byte) {
31+
privKey = self.privKey
32+
if len(privKey) == 0 {
33+
privKey = crypto.GenerateNewKeyPair().PublicKey
34+
self.privKey = privKey
35+
}
36+
return
37+
}
38+
3039
func newTestPeer() (peer *Peer) {
3140
peer = NewPeer(&peerId{}, []Cap{})
3241
peer.pubkeyHook = func(*peerAddr) error { return nil }

0 commit comments

Comments
 (0)