diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-10-02 18:20:41 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-10-02 18:20:41 +0800 |
commit | 47f62a67aa8a033d8a81dc16104018369325897d (patch) | |
tree | 102f70b5ba42e6de4faa9866b7e329c44cf525a9 /eth/downloader/peer.go | |
parent | 49ae53850622f3ea051184dccc867fbfec4c9ecb (diff) | |
download | go-tangerine-47f62a67aa8a033d8a81dc16104018369325897d.tar go-tangerine-47f62a67aa8a033d8a81dc16104018369325897d.tar.gz go-tangerine-47f62a67aa8a033d8a81dc16104018369325897d.tar.bz2 go-tangerine-47f62a67aa8a033d8a81dc16104018369325897d.tar.lz go-tangerine-47f62a67aa8a033d8a81dc16104018369325897d.tar.xz go-tangerine-47f62a67aa8a033d8a81dc16104018369325897d.tar.zst go-tangerine-47f62a67aa8a033d8a81dc16104018369325897d.zip |
eth/downloader: match capabilities when querying idle peers
Diffstat (limited to 'eth/downloader/peer.go')
-rw-r--r-- | eth/downloader/peer.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go index 8fd1f9a99..c1d20ac61 100644 --- a/eth/downloader/peer.go +++ b/eth/downloader/peer.go @@ -312,14 +312,16 @@ func (ps *peerSet) AllPeers() []*peer { // IdlePeers retrieves a flat list of all the currently idle peers within the // active peer set, ordered by their reputation. -func (ps *peerSet) IdlePeers() []*peer { +func (ps *peerSet) IdlePeers(version int) []*peer { ps.lock.RLock() defer ps.lock.RUnlock() list := make([]*peer, 0, len(ps.peers)) for _, p := range ps.peers { - if atomic.LoadInt32(&p.idle) == 0 { - list = append(list, p) + if (version == eth61 && p.version == eth61) || (version >= eth62 && p.version >= eth62) { + if atomic.LoadInt32(&p.idle) == 0 { + list = append(list, p) + } } } for i := 0; i < len(list); i++ { |