pinger

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "/qlc/ping/1.0.0"
View Source
const (
	PingSize = 32
)

Variables

View Source
var ErrPingSelf = errors.New("cannot ping self")

ErrPingSelf is returned if the pinger is instructed to ping itself.

Functions

func FromUint32

func FromUint32(v uint32) []byte

FromUint32 decodes uint32.

func Ping

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

Ping pings the remote peer until the context is canceled, returning a stream of RTTs or errors.

Types

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 (p *PingService) PingHandler(s network.Stream)

type Pinger

type Pinger struct {
	*PingService
	// contains filtered or unexported fields
}

Pinger wraps a libp2p ping service. It exists to serve more helpful error messages in the case a node is pinging itself.

func NewPinger

func NewPinger(h host.Host) *Pinger

NewPinger creates a filecoin pinger provided with a pingService and a PID.

func (*Pinger) Ping

func (p *Pinger) Ping(ctx context.Context, pid peer.ID) (<-chan Result, error)

Ping connects to other nodes on the network to test connections. The Pinger will error if the caller Pings the Pinger's self id.

type Result

type Result struct {
	RTT     time.Duration
	Version string
	Error   error
}

Result is a result of a ping attempt, either an RTT or an error.

Jump to

Keyboard shortcuts

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