Skip to content

Commit

Permalink
Merge pull request #148 from libp2p/feat/supports-alloc
Browse files Browse the repository at this point in the history
Interface to verify if a peer supports a protocol without making allocations.
  • Loading branch information
aarshkshah1992 committed May 14, 2020
2 parents 3faacbd + 34f061a commit 688f105
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/peerstore/peerstore.go
Expand Up @@ -233,5 +233,13 @@ type ProtoBook interface {
AddProtocols(peer.ID, ...string) error
SetProtocols(peer.ID, ...string) error
RemoveProtocols(peer.ID, ...string) error

// SupportsProtocols returns the set of protocols the peer supports from among the given protocols.
// If the returned error is not nil, the result is indeterminate.
SupportsProtocols(peer.ID, ...string) ([]string, error)

// FirstSupportedProtocol returns the first protocol that the peer supports among the given protocols.
// If the peer does not support any of the given protocols, this function will return an empty string and a nil error.
// If the returned error is not nil, the result is indeterminate.
FirstSupportedProtocol(peer.ID, ...string) (string, error)
}

0 comments on commit 688f105

Please sign in to comment.