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

Function setupPubSub

IceFireDB-SQLite/pkg/p2p/p2p.go:355–368  ·  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

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