Documentation ¶
Index ¶
- Constants
- Variables
- func TopicToCid(topic *Topic) cid.Cid
- type PubsubManager
- func (g *PubsubManager) Broadcast(location common.Location, datatype interface{}) error
- func (g *PubsubManager) GetGenesis() common.Hash
- func (g *PubsubManager) PeersForTopic(t *Topic) ([]peer.ID, error)
- func (g *PubsubManager) SetQuaiBackend(consensus quai.ConsensusAPI)
- func (g *PubsubManager) SetReceiveHandler(receiveCb func(peer.ID, string, string, interface{}, common.Location))
- func (g *PubsubManager) Stop() error
- func (g *PubsubManager) Subscribe(location common.Location, datatype interface{}) error
- func (g *PubsubManager) Unsubscribe(location common.Location, datatype interface{}) error
- func (g *PubsubManager) UnsubscribeAll()
- type Topic
Constants ¶
View Source
const ( // Data types for gossipsub topics C_workObjectType = "blocks" C_transactionType = "transactions" C_headerType = "headers" 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 ¶
func NewGossipSubManager ¶
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 (*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 TopicFromString ¶
func (*Topic) GetLocation ¶
func (*Topic) GetRequestDegree ¶ added in v0.30.0
func (*Topic) GetTopicType ¶
func (t *Topic) GetTopicType() interface{}
Click to show internal directories.
Click to hide internal directories.