File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed
Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ func newPeerSet() *peerSet {
7373func (ps * peerSet ) registerSnapExtension (peer * snap.Peer ) error {
7474 // Reject the peer if it advertises `snap` without `eth` as `snap` is only a
7575 // satellite protocol meaningful with the chain selection of `eth`
76- if ! peer .SupportsCap (eth .ProtocolName , eth .ProtocolVersions ) {
76+ if ! peer .RunningCap (eth .ProtocolName , eth .ProtocolVersions ) {
7777 return errSnapWithoutEth
7878 }
7979 // Ensure nobody can double connect
@@ -101,7 +101,7 @@ func (ps *peerSet) registerSnapExtension(peer *snap.Peer) error {
101101// by the peerset.
102102func (ps * peerSet ) waitSnapExtension (peer * eth.Peer ) (* snap.Peer , error ) {
103103 // If the peer does not support a compatible `snap`, don't wait
104- if ! peer .SupportsCap (snap .ProtocolName , snap .ProtocolVersions ) {
104+ if ! peer .RunningCap (snap .ProtocolName , snap .ProtocolVersions ) {
105105 return nil , nil
106106 }
107107 // Ensure nobody can double connect
Original file line number Diff line number Diff line change @@ -158,15 +158,14 @@ func (p *Peer) Caps() []Cap {
158158 return p .rw .caps
159159}
160160
161- // SupportsCap returns true if the peer supports any of the enumerated versions
162- // of a specific protocol.
163- func (p * Peer ) SupportsCap (protocol string , versions []uint ) bool {
164- for _ , cap := range p .rw .caps {
165- if cap .Name == protocol {
166- for _ , ver := range versions {
167- if cap .Version == ver {
168- return true
169- }
161+ // RunningCap returns true if the peer is actively connected using any of the
162+ // enumerated versions of a specific protocol, meaning that at least one of the
163+ // versions is supported by both this node and the peer p.
164+ func (p * Peer ) RunningCap (protocol string , versions []uint ) bool {
165+ if proto , ok := p .running [protocol ]; ok {
166+ for _ , ver := range versions {
167+ if proto .Version == ver {
168+ return true
170169 }
171170 }
172171 }
You can’t perform that action at this time.
0 commit comments