diff options
author | Felix Lange <fjl@twurst.com> | 2015-06-28 19:52:37 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-06-28 19:52:37 +0800 |
commit | a0191910fcc7f4122c90db49f8381e4d3bd58823 (patch) | |
tree | a58ecfde989414dc0682abb39002d6fe074c5125 /p2p/protocol.go | |
parent | b9ebdffd83267ad387facfd2c87133aa8bd3aa62 (diff) | |
parent | 216fc267fafa6e27b14f642d0440cbd817a3a2d3 (diff) | |
download | dexon-a0191910fcc7f4122c90db49f8381e4d3bd58823.tar dexon-a0191910fcc7f4122c90db49f8381e4d3bd58823.tar.gz dexon-a0191910fcc7f4122c90db49f8381e4d3bd58823.tar.bz2 dexon-a0191910fcc7f4122c90db49f8381e4d3bd58823.tar.lz dexon-a0191910fcc7f4122c90db49f8381e4d3bd58823.tar.xz dexon-a0191910fcc7f4122c90db49f8381e4d3bd58823.tar.zst dexon-a0191910fcc7f4122c90db49f8381e4d3bd58823.zip |
Merge pull request #1341 from karalabe/proto-version-negotiation
p2p: support protocol version negotiation
Diffstat (limited to 'p2p/protocol.go')
-rw-r--r-- | p2p/protocol.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/p2p/protocol.go b/p2p/protocol.go index 5fa395eda..a229ba911 100644 --- a/p2p/protocol.go +++ b/p2p/protocol.go @@ -43,8 +43,10 @@ func (cap Cap) String() string { return fmt.Sprintf("%s/%d", cap.Name, cap.Version) } -type capsByName []Cap +type capsByNameAndVersion []Cap -func (cs capsByName) Len() int { return len(cs) } -func (cs capsByName) Less(i, j int) bool { return cs[i].Name < cs[j].Name } -func (cs capsByName) Swap(i, j int) { cs[i], cs[j] = cs[j], cs[i] } +func (cs capsByNameAndVersion) Len() int { return len(cs) } +func (cs capsByNameAndVersion) Swap(i, j int) { cs[i], cs[j] = cs[j], cs[i] } +func (cs capsByNameAndVersion) Less(i, j int) bool { + return cs[i].Name < cs[j].Name || (cs[i].Name == cs[j].Name && cs[i].Version < cs[j].Version) +} |