network

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilHost = errors.New("host is nil")

ErrNilHost is returned when trying to instantiate a network with a nil host

Functions

This section is empty.

Types

type Network

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

Host wraps a libp2p host. It contains the current pubsub state. Host implements the Network interface

func NewNetwork

func NewNetwork(h host.Host) (*Network, error)

NewNetwork returns a Network

func (*Network) AddrInfo

func (n *Network) AddrInfo() peer.AddrInfo

AddrInfo returns the host's AddrInfo

func (*Network) Connect

func (n *Network) Connect(p peer.AddrInfo) error

Connect connects directly to a peer

func (*Network) Messages

func (n *Network) Messages() <-chan []byte

Messages returns the receive-only pubsub message channel

func (*Network) MultiAddrs

func (n *Network) MultiAddrs() []string

func (*Network) PeerID

func (n *Network) PeerID() peer.ID

func (*Network) Peers

func (n *Network) Peers() []peer.ID

func (*Network) Publish

func (n *Network) Publish(ctx context.Context, data []byte) error

Publish publishes some data

func (*Network) RegisterStreamHandler

func (n *Network) RegisterStreamHandler(id core.ProtocolID, handler network.StreamHandler)

RegisterStreamHandler registers a handler and protocol ID on the libp2p host

func (*Network) Send

func (n *Network) Send(ctx context.Context, protocol core.ProtocolID, p peer.ID, data []byte) error

Send opens a stream and sends data to the given peer

func (*Network) Start

func (n *Network) Start() error

Start begins pubsub by subscribing to the markets topic

func (*Network) Stop

func (n *Network) Stop() error

Stop cancels all subscriptions

Jump to

Keyboard shortcuts

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