diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-30 00:33:19 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-30 00:33:19 +0800 |
commit | 9d8b512b27f691fc1980b850e04eb436a3938626 (patch) | |
tree | 97d199539df243eb406f2427dc2cddaf1ed6b158 /p2p/peer.go | |
parent | b0a5be4495962c291a25cbea793e43bad0781510 (diff) | |
parent | a7d22658ad81064abad5a12bd38545c98a0c508c (diff) | |
download | dexon-9d8b512b27f691fc1980b850e04eb436a3938626.tar dexon-9d8b512b27f691fc1980b850e04eb436a3938626.tar.gz dexon-9d8b512b27f691fc1980b850e04eb436a3938626.tar.bz2 dexon-9d8b512b27f691fc1980b850e04eb436a3938626.tar.lz dexon-9d8b512b27f691fc1980b850e04eb436a3938626.tar.xz dexon-9d8b512b27f691fc1980b850e04eb436a3938626.tar.zst dexon-9d8b512b27f691fc1980b850e04eb436a3938626.zip |
Merge pull request #1356 from Gustav-Simonsson/debug_develop
Debug develop
Diffstat (limited to 'p2p/peer.go')
-rw-r--r-- | p2p/peer.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/p2p/peer.go b/p2p/peer.go index 40466cf84..e1bda1d03 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -249,15 +249,22 @@ func countMatchingProtocols(protocols []Protocol, caps []Cap) int { // matchProtocols creates structures for matching named subprotocols. func matchProtocols(protocols []Protocol, caps []Cap, rw MsgReadWriter) map[string]*protoRW { - sort.Sort(capsByName(caps)) + sort.Sort(capsByNameAndVersion(caps)) offset := baseProtocolLength result := make(map[string]*protoRW) + outer: for _, cap := range caps { for _, proto := range protocols { - if proto.Name == cap.Name && proto.Version == cap.Version && result[cap.Name] == nil { + if proto.Name == cap.Name && proto.Version == cap.Version { + // If an old protocol version matched, revert it + if old := result[cap.Name]; old != nil { + offset -= old.Length + } + // Assign the new match result[cap.Name] = &protoRW{Protocol: proto, offset: offset, in: make(chan Msg), w: rw} offset += proto.Length + continue outer } } |