go-waku/waku/v2/protocol/utils.go
Prem Chaitanya Prathi 388f56b43f
feat: Sharded peer management - Relay (#764)
* feat: connect/disconnect to peers based on node topic sub/unsub

* feat: maintain healty relay connections per pubSubTopic

Co-authored-by: richΛrd <info@richardramos.me>

* chore: add config to limit peerstore capacity (#770)
2023-09-27 12:16:37 +05:30

26 lines
699 B
Go

package protocol
import (
"strings"
"github.com/libp2p/go-libp2p/core/protocol"
)
const GossipSubOptimalFullMeshSize = 6
// FulltextMatch is the default matching function used for checking if a peer
// supports a protocol or not
func FulltextMatch(expectedProtocol string) func(string) bool {
return func(receivedProtocol string) bool {
return receivedProtocol == expectedProtocol
}
}
// PrefixTextMatch is a matching function used for checking if a peer's
// supported protocols begin with a particular prefix
func PrefixTextMatch(prefix string) func(protocol.ID) bool {
return func(receivedProtocol protocol.ID) bool {
return strings.HasPrefix(string(receivedProtocol), prefix)
}
}