gossiptopic

package
v0.0.0-...-6862cae Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadEncoding = errors.New("invalid message encoding")

Functions

func MakeTopic

func MakeTopic(h host.Host, topicName string) (*pubsub.Topic, context.CancelFunc, error)

MakeTopic creates a new PubSub object using the default GossipSubRouter as the router, and then joins the named topic. Returns a Topic handle for the joined topic and a CancelFunc to shutdown the PubSub object. Only one Topic handle should exist per topic, and MakeTopic will error if the Topic handle already exists.

Types

type Message

type Message struct {
	Cid       cid.Cid
	Addrs     [][]byte
	ExtraData []byte
	// The OrigPeer field may or may not be present in the serialized data, and
	// the CBOR serializer/deserializer is able to detect that. Only messages
	// that are re-published by an indexer, for consumption by othen indexers,
	// contain this field.
	OrigPeer string
}

Message is the payload of a gossip pubsub message.

func (*Message) GetAddrs

func (m *Message) GetAddrs() ([]multiaddr.Multiaddr, error)

GetAddrs reads the slice of Multiaddr that is stored in the Message as a slice of []byte.

func (*Message) MarshalCBOR

func (m *Message) MarshalCBOR(w io.Writer) error

func (*Message) SetAddrs

func (m *Message) SetAddrs(addrs []multiaddr.Multiaddr)

SetAddrs writes a slice of Multiaddr into the Message as a slice of []byte.

func (*Message) UnmarshalCBOR

func (m *Message) UnmarshalCBOR(r io.Reader) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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