diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-14 19:42:02 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-14 19:42:02 +0800 |
commit | f63cb278038dddd09aa4527529c43fdb8320f2fa (patch) | |
tree | a486e616e7f7fc5c625926b4a5965234fe18643f | |
parent | 954ba211bf8ee63872b5e4d20b6aafb4400507c6 (diff) | |
download | dexon-f63cb278038dddd09aa4527529c43fdb8320f2fa.tar dexon-f63cb278038dddd09aa4527529c43fdb8320f2fa.tar.gz dexon-f63cb278038dddd09aa4527529c43fdb8320f2fa.tar.bz2 dexon-f63cb278038dddd09aa4527529c43fdb8320f2fa.tar.lz dexon-f63cb278038dddd09aa4527529c43fdb8320f2fa.tar.xz dexon-f63cb278038dddd09aa4527529c43fdb8320f2fa.tar.zst dexon-f63cb278038dddd09aa4527529c43fdb8320f2fa.zip |
tmp
-rw-r--r-- | peer.go | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -182,6 +182,7 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer { inbound: false, connected: 0, disconnect: 0, + port: 30303, caps: caps, version: ethereum.ClientIdentity().String(), } @@ -629,17 +630,6 @@ func (p *Peer) pushPeers() { p.QueueMessage(p.peersMessage()) } -func (p *Peer) pushHandshake() error { - pubkey := p.ethereum.KeyManager().PublicKey() - msg := ethwire.NewMessage(ethwire.MsgHandshakeTy, []interface{}{ - uint32(0), []byte(p.version), []string{"eth"}, p.port, pubkey[1:], - }) - - p.QueueMessage(msg) - - return nil -} - func (self *Peer) pushStatus() { const netVersion = 0 msg := ethwire.NewMessage(ethwire.MsgStatusTy, []interface{}{ @@ -673,8 +663,21 @@ func (self *Peer) handleStatus(msg *ethwire.Msg) { ethlogger.Infof("Peer is [ETH] capable. (TD = %v ~ %x", self.td, self.bestHash) } +func (p *Peer) pushHandshake() error { + pubkey := p.ethereum.KeyManager().PublicKey() + fmt.Println("pubkey", pubkey) + msg := ethwire.NewMessage(ethwire.MsgHandshakeTy, []interface{}{ + uint32(0), []byte(p.version), []string{"eth"}, uint32(p.port), pubkey[1:], + }) + + p.QueueMessage(msg) + + return nil +} + func (p *Peer) handleHandshake(msg *ethwire.Msg) { c := msg.Data + fmt.Println(c, c.Len()) var ( p2pVersion = c.Get(0).Uint() @@ -684,8 +687,6 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) { pub = c.Get(4).Bytes() ) - fmt.Println("PEER CAPS", caps) - // Check correctness of p2p protocol version if p2pVersion != P2PVersion { peerlogger.Debugf("Invalid P2P version. Require protocol %d, received %d\n", P2PVersion, p2pVersion) @@ -735,7 +736,7 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) { p.ethereum.PushPeer(p) p.ethereum.reactor.Post("peerList", p.ethereum.Peers()) - ethlogger.Infof("Added peer (%s) %d / %d \n", p.conn.RemoteAddr(), p.ethereum.Peers().Len(), p.ethereum.MaxPeers) + ethlogger.Infof("Added peer (%s) %d / %d (%v)\n", p.conn.RemoteAddr(), p.ethereum.Peers().Len(), p.ethereum.MaxPeers, caps) peerlogger.Debugln(p) |