aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-01-31 18:18:10 +0800
committerobscuren <geffobscura@gmail.com>2014-01-31 18:18:10 +0800
commitdfa38b3f91d124f97350429c4664b62a5cb7dd08 (patch)
tree7589b767c846736fa0c16c383f6ef4cfd5e4568d /ethereum.go
parent36f221dbe7e66568fc3f1680208b73e4ea20c4ef (diff)
downloadgo-tangerine-dfa38b3f91d124f97350429c4664b62a5cb7dd08.tar
go-tangerine-dfa38b3f91d124f97350429c4664b62a5cb7dd08.tar.gz
go-tangerine-dfa38b3f91d124f97350429c4664b62a5cb7dd08.tar.bz2
go-tangerine-dfa38b3f91d124f97350429c4664b62a5cb7dd08.tar.lz
go-tangerine-dfa38b3f91d124f97350429c4664b62a5cb7dd08.tar.xz
go-tangerine-dfa38b3f91d124f97350429c4664b62a5cb7dd08.tar.zst
go-tangerine-dfa38b3f91d124f97350429c4664b62a5cb7dd08.zip
Peer connection checking
Diffstat (limited to 'ethereum.go')
-rw-r--r--ethereum.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/ethereum.go b/ethereum.go
index dd6256f4b..e1fb5945c 100644
--- a/ethereum.go
+++ b/ethereum.go
@@ -93,6 +93,9 @@ func (s *Ethereum) ConnectToPeer(addr string) error {
var alreadyConnected bool
eachPeer(s.peers, func(p *Peer, v *list.Element) {
+ if p.conn == nil {
+ return
+ }
phost, _, _ := net.SplitHostPort(p.conn.RemoteAddr().String())
ahost, _, _ := net.SplitHostPort(addr)
@@ -118,7 +121,7 @@ func (s *Ethereum) OutboundPeers() []*Peer {
outboundPeers := make([]*Peer, s.peers.Len())
length := 0
eachPeer(s.peers, func(p *Peer, e *list.Element) {
- if !p.inbound {
+ if !p.inbound && p.conn != nil {
outboundPeers[length] = p
length++
}