peer supports any protocol

This commit is contained in:
Aarsh Shah
2020-05-08 12:10:14 +05:30
parent b1f58c0365
commit 7a58f873f4
5 changed files with 56 additions and 1 deletions

View File

@@ -163,3 +163,20 @@ func (pb *memoryProtoBook) SupportsProtocols(p peer.ID, protos ...string) ([]str
return out, nil
}
func (pb *memoryProtoBook) SupportsAnyProtocol(p peer.ID, protos ...string) (bool, error) {
if err := p.Validate(); err != nil {
return false, err
}
s := pb.segments.get(p)
s.RLock()
defer s.RUnlock()
for _, proto := range protos {
if _, ok := s.protocols[p][proto]; ok {
return true, nil
}
}
return false, nil
}