diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-26 20:48:50 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-26 20:48:50 +0800 |
commit | d84638bd31878f772c6d1de3b491160319ddfc4b (patch) | |
tree | a89ab7e943253f69fb8323da3940011cb36d57d9 /p2p/protocol.go | |
parent | b0a5be4495962c291a25cbea793e43bad0781510 (diff) | |
download | dexon-d84638bd31878f772c6d1de3b491160319ddfc4b.tar.gz dexon-d84638bd31878f772c6d1de3b491160319ddfc4b.tar.zst dexon-d84638bd31878f772c6d1de3b491160319ddfc4b.zip |
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) +} |