|
|
@ -76,9 +76,6 @@ type Peer struct { |
|
|
|
// this to prevent receiving false peers.
|
|
|
|
// this to prevent receiving false peers.
|
|
|
|
requestedPeerList bool |
|
|
|
requestedPeerList bool |
|
|
|
|
|
|
|
|
|
|
|
// Determines whether this is a seed peer
|
|
|
|
|
|
|
|
seed bool |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
host []byte |
|
|
|
host []byte |
|
|
|
port uint16 |
|
|
|
port uint16 |
|
|
|
caps Caps |
|
|
|
caps Caps |
|
|
@ -123,7 +120,7 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer { |
|
|
|
atomic.StoreInt32(&p.connected, 1) |
|
|
|
atomic.StoreInt32(&p.connected, 1) |
|
|
|
atomic.StoreInt32(&p.disconnect, 0) |
|
|
|
atomic.StoreInt32(&p.disconnect, 0) |
|
|
|
|
|
|
|
|
|
|
|
p.Start(false) |
|
|
|
p.Start() |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
return p |
|
|
|
return p |
|
|
@ -155,14 +152,6 @@ func (p *Peer) writeMessage(msg *ethwire.Msg) { |
|
|
|
p.Stop() |
|
|
|
p.Stop() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// XXX TMP CODE FOR TESTNET
|
|
|
|
|
|
|
|
switch msg.Type { |
|
|
|
|
|
|
|
case ethwire.MsgPeersTy: |
|
|
|
|
|
|
|
if p.seed { |
|
|
|
|
|
|
|
p.Stop() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Outbound message handler. Outbound messages are handled here
|
|
|
|
// Outbound message handler. Outbound messages are handled here
|
|
|
@ -349,9 +338,7 @@ func unpackAddr(value *ethutil.RlpValue, p uint64) string { |
|
|
|
return net.JoinHostPort(host, port) |
|
|
|
return net.JoinHostPort(host, port) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (p *Peer) Start(seed bool) { |
|
|
|
func (p *Peer) Start() { |
|
|
|
p.seed = seed |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
peerHost, peerPort, _ := net.SplitHostPort(p.conn.LocalAddr().String()) |
|
|
|
peerHost, peerPort, _ := net.SplitHostPort(p.conn.LocalAddr().String()) |
|
|
|
servHost, servPort, _ := net.SplitHostPort(p.conn.RemoteAddr().String()) |
|
|
|
servHost, servPort, _ := net.SplitHostPort(p.conn.RemoteAddr().String()) |
|
|
|
if peerHost == servHost { |
|
|
|
if peerHost == servHost { |
|
|
|