aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/protocol.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-26 20:48:50 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-26 20:48:50 +0800
commitd84638bd31878f772c6d1de3b491160319ddfc4b (patch)
treea89ab7e943253f69fb8323da3940011cb36d57d9 /p2p/protocol.go
parentb0a5be4495962c291a25cbea793e43bad0781510 (diff)
downloadgo-tangerine-d84638bd31878f772c6d1de3b491160319ddfc4b.tar
go-tangerine-d84638bd31878f772c6d1de3b491160319ddfc4b.tar.gz
go-tangerine-d84638bd31878f772c6d1de3b491160319ddfc4b.tar.bz2
go-tangerine-d84638bd31878f772c6d1de3b491160319ddfc4b.tar.lz
go-tangerine-d84638bd31878f772c6d1de3b491160319ddfc4b.tar.xz
go-tangerine-d84638bd31878f772c6d1de3b491160319ddfc4b.tar.zst
go-tangerine-d84638bd31878f772c6d1de3b491160319ddfc4b.zip
p2p: support protocol version negotiation
Diffstat (limited to 'p2p/protocol.go')
-rw-r--r--p2p/protocol.go10
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)
+}