Documentation ¶
Index ¶
- Constants
- func ConnectToPeer(host host.Host, ctx context.Context, address string) error
- func NewNetworkMessenger(ctx context.Context, port int, p2pPrivKey libp2pCrypto.PrivKey, ...) (*networkMessenger, error)
- func NewNetworkMessengerOnFreePort(ctx context.Context, p2pPrivKey libp2pCrypto.PrivKey, ...) (*networkMessenger, error)
- type Message
Constants ¶
const ListenAddrWithIp4AndTcp = "/ip4/0.0.0.0/tcp/"
ListenAddrWithIp4AndTcp defines the listening address with ip v.4 and TCP
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 ¶
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) IsInterfaceNil ¶
IsInterfaceNil returns true if there is no value under the interface
func (*Message) Key ¶
Key returns the message public key (if it can not be recovered from From field)