libp2p

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ListenAddrWithIp4AndTcp = "/ip4/0.0.0.0/tcp/"

ListenAddrWithIp4AndTcp defines the listening address with ip v.4 and TCP

View Source
const ListenLocalhostAddrWithIp4AndTcp = "/ip4/127.0.0.1/tcp/"

ListenLocalhostAddrWithIp4AndTcp defines the local host listening ip v.4 address and TCP

Variables

This section is empty.

Functions

func ConnectToPeer

func ConnectToPeer(host host.Host, ctx context.Context, address string) error

ConnectToPeer connects the host to a provided address

func NewNetworkMessenger

func NewNetworkMessenger(
	ctx context.Context,
	port int,
	p2pPrivKey libp2pCrypto.PrivKey,
	conMgr connmgr.ConnManager,
	_ interface{},
	peerDiscoverer p2p.PeerDiscoverer,
	listenAddress string,
	_ int,
) (*networkMessenger, error)

NewNetworkMessenger creates a libP2P messenger by opening a port on the current machine Should be used in production!

func NewNetworkMessengerOnFreePort

func NewNetworkMessengerOnFreePort(
	ctx context.Context,
	p2pPrivKey libp2pCrypto.PrivKey,
	conMgr connmgr.ConnManager,
	peerDiscoverer p2p.PeerDiscoverer,
) (*networkMessenger, error)

NewNetworkMessengerOnFreePort tries to create a new NetworkMessenger on a free port found in the system Should be used only in testing!

Types

type Message

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

Message is a data holder struct

func NewMessage

func NewMessage(message *pubsub.Message) *Message

NewMessage returns a new instance of a Message object

func (*Message) Data

func (m *Message) Data() []byte

Data returns the message payload

func (*Message) From

func (m *Message) From() []byte

From returns the message originator's peer ID

func (*Message) IsInterfaceNil

func (m *Message) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Message) Key

func (m *Message) Key() []byte

Key returns the message public key (if it can not be recovered from From field)

func (*Message) Peer

func (m *Message) Peer() p2p.PeerID

Peer returns the peer that originated the message

func (*Message) SeqNo

func (m *Message) SeqNo() []byte

SeqNo returns the message sequence number

func (*Message) Signature

func (m *Message) Signature() []byte

Signature returns the message signature

func (*Message) TopicIDs

func (m *Message) TopicIDs() []string

TopicIDs returns the topic on which the message was sent

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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