aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--peer.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/peer.go b/peer.go
index 6257e32a4..c5e0f9ac9 100644
--- a/peer.go
+++ b/peer.go
@@ -128,7 +128,8 @@ func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer {
}
func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
- pubkey, _ := ethutil.Config.Db.Get([]byte("Pubkey"))
+ data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
+ pubkey := ethutil.NewValueFromBytes(data).Get(2).Bytes()
p := &Peer{
outputQueue: make(chan *ethwire.Msg, outputBufferSize),
@@ -382,14 +383,6 @@ func (p *Peer) Start() {
peerHost, peerPort, _ := net.SplitHostPort(p.conn.LocalAddr().String())
servHost, servPort, _ := net.SplitHostPort(p.conn.RemoteAddr().String())
- pubkey, _ := ethutil.Config.Db.Get([]byte("Pubkey"))
- if bytes.Compare(pubkey, p.pubkey) == 0 {
- log.Println("self connect")
- p.Stop()
-
- return
- }
-
if p.inbound {
p.host, p.port = packAddr(peerHost, peerPort)
} else {
@@ -468,6 +461,14 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) {
p.pubkey = c.Get(3).AsBytes()
p.port = uint16(c.Get(5).AsUint())
+ data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
+ pubkey := ethutil.NewValueFromBytes(data).Get(2).Bytes()
+ if bytes.Compare(pubkey, p.pubkey) == 0 {
+ p.Stop()
+
+ return
+ }
+
istr = "inbound"
} else {
msg := ethwire.NewMessage(ethwire.MsgGetChainTy, []interface{}{p.ethereum.BlockManager.BlockChain().CurrentBlock.Hash(), uint64(100)})