From d4f0a67323dec12e5b84ba4907970267a2e27601 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 8 May 2015 16:09:38 +0200 Subject: p2p: drop connections with no matching protocols --- p2p/peer.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'p2p/peer.go') 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)) -- cgit