Source File
gossipsub_feat.go
Belonging Package
github.com/libp2p/go-libp2p-pubsub
package pubsubimport ()// GossipSubFeatureTest is a feature test function; it takes a feature and a protocol ID and// should return true if the feature is supported by the protocoltype GossipSubFeatureTest = func(GossipSubFeature, protocol.ID) bool// GossipSubFeature is a feature discriminant enumtype GossipSubFeature intconst (// Protocol supports basic GossipSub Mesh -- gossipsub-v1.0 compatibleGossipSubFeatureMesh = iota// Protocol supports Peer eXchange on prune -- gossipsub-v1.1 compatibleGossipSubFeaturePX// Protocol supports IDONTWANT -- gossipsub-v1.2 compatibleGossipSubFeatureIdontwant)// GossipSubDefaultProtocols is the default gossipsub router protocol listvar GossipSubDefaultProtocols = []protocol.ID{GossipSubID_v12, GossipSubID_v11, GossipSubID_v10, FloodSubID}// GossipSubDefaultFeatures is the feature test function for the default gossipsub protocolsfunc ( GossipSubFeature, protocol.ID) bool {switch {case GossipSubFeatureMesh:return == GossipSubID_v12 || == GossipSubID_v11 || == GossipSubID_v10case GossipSubFeaturePX:return == GossipSubID_v12 || == GossipSubID_v11case GossipSubFeatureIdontwant:return == GossipSubID_v12default:return false}}// WithGossipSubProtocols is a gossipsub router option that configures a custom protocol list// and feature test functionfunc ( []protocol.ID, GossipSubFeatureTest) Option {return func( *PubSub) error {, := .rt.(*GossipSubRouter)if ! {return fmt.Errorf("pubsub router is not gossipsub")}.protos =.feature =return nil}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |