diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-18 04:40:05 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-18 04:40:05 +0800 |
commit | 142e81258cd7b77226d706c84f93da417aaaf426 (patch) | |
tree | 3b84c4139d100252512db487c33e2be57191e5d3 /p2p/server.go | |
parent | 86661de07746cd4e4ad8d016afee9fa8074aa141 (diff) | |
parent | 048d4ec5be5352dcb06f5123e3458b99aa151e6b (diff) | |
download | go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.gz go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.bz2 go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.lz go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.xz go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.tar.zst go-tangerine-142e81258cd7b77226d706c84f93da417aaaf426.zip |
Merge branch 'develop' into conversion
Diffstat (limited to 'p2p/server.go')
-rw-r--r-- | p2p/server.go | 14 |
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 |