p2p

package
v0.0.0-...-8cb8a38 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 16 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)

GetNodeID returns the node ID with the given private key.

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 PeerIDsFromAddrInfos

func PeerIDsFromAddrInfos(addrInfos []*peer.AddrInfo) []peer.ID

PeerIDsFromAddrInfos returns a slice of peer IDs from the given slice of peer.AddrInfo.

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
	PeerList []peer.ID
	// contains filtered or unexported fields
}

func NewNode

func NewNode(ctx context.Context, 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) GetMultiAddress

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

type NodeOptions

type NodeOptions struct {
	Port              uint16
	NetworkPrivateKey pnet.PSK       // Shared secret for private network
	NodePrivateKey    crypto.PrivKey // Private key for current node
	PeerList          []peer.ID      // Allowlist of peers to connect to
	EchoRequiredPeers int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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