pubsubManager

package
v0.31.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Data types for gossipsub topics
	C_workObjectType                    = "blocks"
	C_transactionType                   = "transactions"
	C_headerType                        = "headers"
	C_workObjectShareType               = "workshare"
	C_workObjectRequestDegree           = 3
	C_workObjectHeaderTypeRequestDegree = 3
	C_defaultRequestDegree              = 3
)

Variables

View Source
var (
	ErrUnsupportedType = errors.New("data type not supported")
)

Functions

func TopicToCid

func TopicToCid(topic *Topic) cid.Cid

Creates a Cid from a location to be used as DHT key

Types

type PubsubManager

type PubsubManager struct {
	*pubsub.PubSub
	// contains filtered or unexported fields
}

func NewGossipSubManager

func NewGossipSubManager(ctx context.Context, h host.Host) (*PubsubManager, error)

creates a new gossipsub instance TODO: what options do we need for quai network? See: See https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub@v0.10.0#Option

func (*PubsubManager) Broadcast

func (g *PubsubManager) Broadcast(location common.Location, datatype interface{}) error

broadcasts data to subscribing peers

func (*PubsubManager) GetGenesis

func (g *PubsubManager) GetGenesis() common.Hash

func (*PubsubManager) PeersForTopic

func (g *PubsubManager) PeersForTopic(t *Topic) ([]peer.ID, error)

lists our peers which provide the associated topic

func (*PubsubManager) SetQuaiBackend

func (g *PubsubManager) SetQuaiBackend(consensus quai.ConsensusAPI)

func (*PubsubManager) SetReceiveHandler

func (g *PubsubManager) SetReceiveHandler(receiveCb func(peer.ID, string, string, interface{}, common.Location))

func (*PubsubManager) Stop

func (g *PubsubManager) Stop() error

func (*PubsubManager) Subscribe

func (g *PubsubManager) Subscribe(location common.Location, datatype interface{}) error

subscribe to broadcasts of the given type of data

func (*PubsubManager) Unsubscribe

func (g *PubsubManager) Unsubscribe(location common.Location, datatype interface{}) error

unsubscribe from broadcasts of the given type of data

func (*PubsubManager) UnsubscribeAll

func (g *PubsubManager) UnsubscribeAll()

type Topic

type Topic struct {
	// contains filtered or unexported fields
}

func NewTopic

func NewTopic(genesis common.Hash, location common.Location, data interface{}) (*Topic, error)

gets the name of the topic for the given type of data

func TopicFromString

func TopicFromString(topic string) (*Topic, error)

func (*Topic) GetLocation

func (t *Topic) GetLocation() common.Location

func (*Topic) GetRequestDegree added in v0.30.0

func (t *Topic) GetRequestDegree() int

func (*Topic) GetTopicType

func (t *Topic) GetTopicType() interface{}

func (*Topic) String

func (t *Topic) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL