p2p

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PreSharedNetworkKeyLengthBytes = 32
)

Variables

This section is empty.

Functions

func GetNodeID

func GetNodeID(privKey crypto.PrivKey) (peer.ID, error)

func ParseMultiAddrSlice

func ParseMultiAddrSlice(addrStrings []string) ([]*peer.AddrInfo, error)

ParseMultiAddrSlice parses a slice of multiaddrs strings into a slice of addr info Requires a valid multiaddr string *and* a valid peer ID.

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (crypto.PrivKey, error)

UnmarshalPrivateKey unmarshals a private key from bytes

Types

type Node

type Node struct {
	Host        host.Host
	EchoService *service.EchoService
	// contains filtered or unexported fields
}

func NewNode

func NewNode(options NodeOptions, done chan bool) (*Node, error)

func (Node) Close

func (n Node) Close() error

Close cleans up and stops the node

func (Node) ConnectToPeers

func (n Node) ConnectToPeers(ctx context.Context, peerAddrInfos []*peer.AddrInfo) error

func (Node) EchoPeers

func (n Node) EchoPeers(ctx context.Context) error

func (Node) GetMultiAddress

func (n Node) GetMultiAddress() ([]ma.Multiaddr, error)

type NodeOptions

type NodeOptions struct {
	Port              uint16
	NetworkPrivateKey pnet.PSK
	NodePrivateKey    crypto.PrivKey
	EchoRequiredPeers int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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