diff options
author | Felix Lange <fjl@twurst.com> | 2015-05-08 22:09:38 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-05-08 22:09:55 +0800 |
commit | d4f0a67323dec12e5b84ba4907970267a2e27601 (patch) | |
tree | 1136276c2c0a3a1067edc1ec4d05858bc1bbc4fb /p2p/peer.go | |
parent | e45d9bb29d3c04d57fd40533b43ea7929b6a4513 (diff) | |
download | dexon-d4f0a67323dec12e5b84ba4907970267a2e27601.tar dexon-d4f0a67323dec12e5b84ba4907970267a2e27601.tar.gz dexon-d4f0a67323dec12e5b84ba4907970267a2e27601.tar.bz2 dexon-d4f0a67323dec12e5b84ba4907970267a2e27601.tar.lz dexon-d4f0a67323dec12e5b84ba4907970267a2e27601.tar.xz dexon-d4f0a67323dec12e5b84ba4907970267a2e27601.tar.zst dexon-d4f0a67323dec12e5b84ba4907970267a2e27601.zip |
p2p: drop connections with no matching protocols
Diffstat (limited to 'p2p/peer.go')
-rw-r--r-- | p2p/peer.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/p2p/peer.go b/p2p/peer.go index cdf9ba965..ac691f2ce 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -211,6 +211,18 @@ func (p *Peer) handle(msg Msg) error { return nil } +func countMatchingProtocols(protocols []Protocol, caps []Cap) int { + n := 0 + for _, cap := range caps { + for _, proto := range protocols { + if proto.Name == cap.Name && proto.Version == cap.Version { + n++ + } + } + } + return n +} + // matchProtocols creates structures for matching named subprotocols. func matchProtocols(protocols []Protocol, caps []Cap, rw MsgReadWriter) map[string]*protoRW { sort.Sort(capsByName(caps)) |