MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / setupPubSub

Function setupPubSub

IceFireDB-SQLProxy/pkg/p2p/p2p.go:356–369  ·  view source on GitHub ↗

A function that generates a PubSub Handler object and returns it Requires a node host and a routing discovery service.

(ctx context.Context, nodehost host.Host, routingdiscovery *discoveryRouting.RoutingDiscovery)

Source from the content-addressed store, hash-verified

354// A function that generates a PubSub Handler object and returns it
355// Requires a node host and a routing discovery service.
356func setupPubSub(ctx context.Context, nodehost host.Host, routingdiscovery *discoveryRouting.RoutingDiscovery) *pubsub.PubSub {
357 // Create a new PubSub service which uses a GossipSub router
358 pubsubhandler, err := pubsub.NewGossipSub(ctx, nodehost, pubsub.WithDiscovery(routingdiscovery))
359 // Handle any potential error
360 if err != nil {
361 logrus.WithFields(logrus.Fields{
362 "error": err.Error(),
363 "type": "GossipSub",
364 }).Fatalln("PubSub Handler Creation Failed!")
365 }
366
367 // Return the PubSub handler
368 return pubsubhandler
369}
370
371// A function that bootstraps a given Kademlia DHT to satisfy the IPFS router
372// interface and connects to all the bootstrap peers provided by libp2p

Callers 1

NewP2PFunction · 0.70

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected