caps.go 707 B

1234567891011121314151617181920212223242526272829
  1. package p2p
  2. import "fmt"
  3. var OurCaps = []Cap{
  4. {Name: "diff", Version: 1},
  5. {Name: "snap", Version: 1},
  6. {Name: "eth", Version: 65},
  7. {Name: "eth", Version: 66},
  8. {Name: "eth", Version: 67},
  9. }
  10. // Cap is the structure of a peer capability.
  11. type Cap struct {
  12. Name string
  13. Version uint
  14. }
  15. func (cap Cap) String() string {
  16. return fmt.Sprintf("%s/%d", cap.Name, cap.Version)
  17. }
  18. type capsByNameAndVersion []Cap
  19. func (cs capsByNameAndVersion) Len() int { return len(cs) }
  20. func (cs capsByNameAndVersion) Swap(i, j int) { cs[i], cs[j] = cs[j], cs[i] }
  21. func (cs capsByNameAndVersion) Less(i, j int) bool {
  22. return cs[i].Name < cs[j].Name || (cs[i].Name == cs[j].Name && cs[i].Version < cs[j].Version)
  23. }