p2p: use slices.Contains

Signed-off-by: deepdring <deepdrink@icloud.com>
This commit is contained in:
deepdring 2025-08-14 22:37:58 +08:00
parent 2dbb580f51
commit 8b9b816da3

View file

@ -182,10 +182,8 @@ func (p *Peer) Caps() []Cap {
// versions is supported by both this node and the peer p. // versions is supported by both this node and the peer p.
func (p *Peer) RunningCap(protocol string, versions []uint) bool { func (p *Peer) RunningCap(protocol string, versions []uint) bool {
if proto, ok := p.running[protocol]; ok { if proto, ok := p.running[protocol]; ok {
for _, ver := range versions { if slices.Contains(versions, proto.Version) {
if proto.Version == ver { return true
return true
}
} }
} }
return false return false