diff options
author | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-07-01 22:16:05 +0800 |
---|---|---|
committer | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-07-01 22:16:05 +0800 |
commit | 29f613ef84ed39ccc1929dd1069f3576ade889f1 (patch) | |
tree | 0c12e6fe9e0214989401bb47a6d4503081fd47bc /peer.go | |
parent | 550407b0ec78b7026737d1abe28127da8c0c9063 (diff) | |
parent | ff5703fd9b089de67811af61de05637c62dc7a2c (diff) | |
download | dexon-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar dexon-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.gz dexon-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.bz2 dexon-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.lz dexon-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.xz dexon-29f613ef84ed39ccc1929dd1069f3576ade889f1.tar.zst dexon-29f613ef84ed39ccc1929dd1069f3576ade889f1.zip |
Merge pull request #28 from ethersphere/feature/keys
Feature/keys
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -146,7 +146,7 @@ type Peer struct { } func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer { - pubkey := ethutil.GetKeyRing().Get(0).PublicKey[1:] + pubkey := ethereum.KeyManager().PublicKey()[1:] return &Peer{ outputQueue: make(chan *ethwire.Msg, outputBufferSize), @@ -590,16 +590,12 @@ func (p *Peer) Stop() { } func (p *Peer) pushHandshake() error { - keyRing := ethutil.GetKeyRing().Get(0) - if keyRing != nil { - pubkey := keyRing.PublicKey - - msg := ethwire.NewMessage(ethwire.MsgHandshakeTy, []interface{}{ - uint32(ProtocolVersion), uint32(0), []byte(p.version), byte(p.caps), p.port, pubkey[1:], - }) + pubkey := p.ethereum.KeyManager().PublicKey() + msg := ethwire.NewMessage(ethwire.MsgHandshakeTy, []interface{}{ + uint32(ProtocolVersion), uint32(0), []byte(p.version), byte(p.caps), p.port, pubkey[1:], + }) - p.QueueMessage(msg) - } + p.QueueMessage(msg) return nil } @@ -664,8 +660,8 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) { p.port = uint16(c.Get(4).Uint()) // Self connect detection - keyPair := ethutil.GetKeyRing().Get(0) - if bytes.Compare(keyPair.PublicKey, p.pubkey) == 0 { + pubkey := p.ethereum.KeyManager().PublicKey() + if bytes.Compare(pubkey, p.pubkey) == 0 { p.Stop() return |