aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/server.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-18 04:27:34 +0800
committerobscuren <geffobscura@gmail.com>2015-03-18 04:27:34 +0800
commit917050dc30d8717d7e0bba1257165c1aec44887f (patch)
tree712f8823391286438a0e5c3d1f53c4682254650e /p2p/server.go
parentfe819f3b9f7a2d8d842c53b7269ccceace533569 (diff)
parent53104b09fa823cb5457960b8518b9650a5b083da (diff)
downloaddexon-917050dc30d8717d7e0bba1257165c1aec44887f.tar
dexon-917050dc30d8717d7e0bba1257165c1aec44887f.tar.gz
dexon-917050dc30d8717d7e0bba1257165c1aec44887f.tar.bz2
dexon-917050dc30d8717d7e0bba1257165c1aec44887f.tar.lz
dexon-917050dc30d8717d7e0bba1257165c1aec44887f.tar.xz
dexon-917050dc30d8717d7e0bba1257165c1aec44887f.tar.zst
dexon-917050dc30d8717d7e0bba1257165c1aec44887f.zip
Merge branch 'develop' into rpcfrontier
Diffstat (limited to 'p2p/server.go')
-rw-r--r--p2p/server.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/p2p/server.go b/p2p/server.go
index 02f1b8572..9c148ba39 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -180,7 +180,7 @@ func (srv *Server) Start() (err error) {
srv.ntab = ntab
// handshake
- srv.ourHandshake = &protoHandshake{Version: baseProtocolVersion, Name: srv.Name, ID: ntab.Self()}
+ srv.ourHandshake = &protoHandshake{Version: baseProtocolVersion, Name: srv.Name, ID: ntab.Self().ID}
for _, p := range srv.Protocols {
srv.ourHandshake.Caps = append(srv.ourHandshake.Caps, p.cap())
}
@@ -298,7 +298,7 @@ func (srv *Server) dialLoop() {
srv.lock.Lock()
_, isconnected := srv.peers[dest.ID]
srv.lock.Unlock()
- if isconnected || dialing[dest.ID] || dest.ID == srv.ntab.Self() {
+ if isconnected || dialing[dest.ID] || dest.ID == srv.Self().ID {
continue
}
@@ -332,12 +332,16 @@ func (srv *Server) dialNode(dest *discover.Node) {
srv.startPeer(conn, dest)
}
+func (srv *Server) Self() *discover.Node {
+ return srv.ntab.Self()
+}
+
func (srv *Server) findPeers() {
- far := srv.ntab.Self()
+ far := srv.Self().ID
for i := range far {
far[i] = ^far[i]
}
- closeToSelf := srv.ntab.Lookup(srv.ntab.Self())
+ closeToSelf := srv.ntab.Lookup(srv.Self().ID)
farFromSelf := srv.ntab.Lookup(far)
for i := 0; i < len(closeToSelf) || i < len(farFromSelf); i++ {
@@ -402,7 +406,7 @@ func (srv *Server) addPeer(id discover.NodeID, p *Peer) (bool, DiscReason) {
return false, DiscTooManyPeers
case srv.peers[id] != nil:
return false, DiscAlreadyConnected
- case id == srv.ntab.Self():
+ case id == srv.Self().ID:
return false, DiscSelf
}
srv.peers[id] = p