Closed richard-ramos closed 3 years ago
This allows setting a custom protocol matching function.
fullTextMatch := func(expectedProtocol string) func(string) bool { return func(protocolToVerify string) bool { return protocolToVerify == expectedProtocol } } // create a new PubSub service using the GossipSub router ps, err := pubsub.NewGossipSub(ctx, h, pubsub.WithProtocolMatchFunction(fullTextMatch))
Could potentially be used to allow semver matching
protoMinor := protocol.ID("/testing/1.2.0") mfunc, err := helpers.MultistreamSemverMatcher(protoMinor) if err != nil { t.Fatal(err) } ps, err := pubsub.NewGossipSub(ctx, h, pubsub.WithProtocolMatchFunction(mfunc), pubsub.WithGossipSubProtocols([]protocol.ID{pubsub.GossipSubID_v11, pubsub.GossipSubID_v10, pubsub.FloodSubID, protoMinor}, pubsub.GossipSubDefaultFeatures) )
Also, can you add a test?
I finished the required changes. Thank you for the code review!
thank you!
This allows setting a custom protocol matching function.
Could potentially be used to allow semver matching