|
|
@@ -158,15 +158,14 @@ func (p *Peer) Caps() []Cap {
|
|
|
return p.rw.caps
|
|
|
}
|
|
|
|
|
|
-// SupportsCap returns true if the peer supports any of the enumerated versions
|
|
|
-// of a specific protocol.
|
|
|
-func (p *Peer) SupportsCap(protocol string, versions []uint) bool {
|
|
|
- for _, cap := range p.rw.caps {
|
|
|
- if cap.Name == protocol {
|
|
|
- for _, ver := range versions {
|
|
|
- if cap.Version == ver {
|
|
|
- return true
|
|
|
- }
|
|
|
+// RunningCap returns true if the peer is actively connected using any of the
|
|
|
+// enumerated versions of a specific protocol, meaning that at least one of the
|
|
|
+// versions is supported by both this node and the peer p.
|
|
|
+func (p *Peer) RunningCap(protocol string, versions []uint) bool {
|
|
|
+ if proto, ok := p.running[protocol]; ok {
|
|
|
+ for _, ver := range versions {
|
|
|
+ if proto.Version == ver {
|
|
|
+ return true
|
|
|
}
|
|
|
}
|
|
|
}
|