p2p

package
v0.0.0-...-6b2b62e Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Overview

Package p2p provides p2p connectivity for chestnut.

Package p2p provides a native implementation of the p2p network protocol.

Package p2p provides p2p connectivity for chestnut.

Package p2p provides p2p connectivity for chestnut.

Index

Constants

View Source
const (
	PingSize = 32
	PingID   = "/chestnut/ping/1.0.0"
)
View Source
const ProtocolPrefix = "/chestnut"

Variables

This section is empty.

Functions

func Ping

func Ping(ctx context.Context, h host.Host, p peer.ID) <-chan Result

Types

type Node

type Node struct {
	PeerID           peer.ID
	Host             host.Host
	NetworkName      string
	Pubsub           *pubsub.PubSub
	Ddht             *dual.DHT
	Info             *NodeInfo
	RoutingDiscovery *discovery.RoutingDiscovery
}

func NewNode

func NewNode(ctx context.Context, nodeopt *options.NodeOptions, isBootstrap bool, ds *dsbadger2.Datastore, key *ethkeystore.Key, cmgr *connmgr.BasicConnMgr, listenAddresses []maddr.Multiaddr, jsontracerfile string) (*Node, error)

func (*Node) AddPeers

func (node *Node) AddPeers(ctx context.Context, peers []peer.AddrInfo) int

func (*Node) Bootstrap

func (node *Node) Bootstrap(ctx context.Context, config cli.Config) error

func (*Node) ConnectPeers

func (node *Node) ConnectPeers(ctx context.Context, peerok chan struct{}, maxpeers int, config cli.Config) error

func (*Node) FindPeers

func (node *Node) FindPeers(ctx context.Context, RendezvousString string) ([]peer.AddrInfo, error)

func (*Node) PeersProtocol

func (node *Node) PeersProtocol() *map[string][]string

PeerProtocols returns the protocols supported by the peer.

type NodeInfo

type NodeInfo struct {
	NATType network.Reachability
}

type PSPing

type PSPing struct {
	Topic        *pubsub.Topic
	Subscription *pubsub.Subscription
	PeerId       peer.ID
	// contains filtered or unexported fields
}

func NewPSPingService

func NewPSPingService(ctx context.Context, ps *pubsub.PubSub, peerid peer.ID) *PSPing

func (*PSPing) EnablePing

func (p *PSPing) EnablePing() error

func (*PSPing) PingReq

func (p *PSPing) PingReq(dstpeerid string) ([10]int64, error)

type PingResult

type PingResult struct {
	Seqnum  int32
	Req_at  int64
	Resp_at int64
}

type PingService

type PingService struct {
	Host host.Host
}

func NewPingService

func NewPingService(h host.Host) *PingService

func (*PingService) Ping

func (ps *PingService) Ping(ctx context.Context, p peer.ID) <-chan Result

func (*PingService) PingHandler

func (ps *PingService) PingHandler(s network.Stream)

type Result

type Result struct {
	RTT   time.Duration
	Error error
}

Jump to

Keyboard shortcuts

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