p2p

package
v0.8.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

func New

func New(addr, userAgent, bootPeers, privKeyStr string, snNetwork utils.Network, log utils.SimpleLogger) (*Service, error)

func NewWithHost added in v0.6.0

func NewWithHost(p2phost host.Host, bootPeers string, snNetwork utils.Network, log utils.SimpleLogger) (*Service, error)

func (*Service) ListenAddrs

func (s *Service) ListenAddrs() ([]multiaddr.Multiaddr, error)

func (*Service) NewStream added in v0.6.0

func (s *Service) NewStream(ctx context.Context, pids ...protocol.ID) (network.Stream, error)

NewStream creates a bidirectional connection to a random peer that implements a set of protocol ids

func (*Service) PublishOnTopic added in v0.6.0

func (s *Service) PublishOnTopic(topic string, data []byte) error

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run starts the p2p service. Calling any other function before run is undefined behaviour

func (*Service) SetProtocolHandler added in v0.6.0

func (s *Service) SetProtocolHandler(pid protocol.ID, handler func(network.Stream))

func (*Service) SubscribePeerConnectednessChanged

func (s *Service) SubscribePeerConnectednessChanged(ctx context.Context) (<-chan event.EvtPeerConnectednessChanged, error)

func (*Service) SubscribeToTopic added in v0.6.0

func (s *Service) SubscribeToTopic(topic string) (chan []byte, func(), error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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