p2p

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenKeyPair added in v0.10.0

func GenKeyPair() (crypto.PrivKey, crypto.PubKey, peer.ID, error)

Note: the curve used to generate the key pair will mostly likely change in the future.

Types

type Service

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

func New

func New(addr, userAgent, peers, privKeyStr string, feederNode bool, bc *blockchain.Blockchain, snNetwork *utils.Network,
	log utils.SimpleLogger,
) (*Service, error)

func NewWithHost added in v0.6.0

func NewWithHost(p2phost host.Host, peers string, feederNode bool, bc *blockchain.Blockchain, 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) 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)

func (*Service) WithListener added in v0.10.0

func (s *Service) WithListener(l junoSync.EventListener)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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