tracker

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: GPL-3.0, LGPL-3.0 Imports: 8 Imported by: 155

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMatchingRequest = errors.New("no matching request")
	ErrTooManyItems      = errors.New("response is larger than request allows")
	ErrCollision         = errors.New("request ID collision")
	ErrCodeMismatch      = errors.New("wrong response code for request")
	ErrLimitReached      = errors.New("request limit reached")
	ErrStopped           = errors.New("tracker stopped")
)

Functions

This section is empty.

Types

type Request added in v1.17.0

type Request struct {
	ID       uint64 // Request ID
	Size     int    // Number/size of requested items
	ReqCode  uint64 // Protocol message code of the request
	RespCode uint64 // Protocol message code of the expected response
	// contains filtered or unexported fields
}

Request tracks sent network requests which have not yet received a response.

type Response added in v1.17.0

type Response struct {
	ID      uint64 // Request ID of the response
	MsgCode uint64 // Protocol message code
	Size    int    // number/size of items in response
}

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker is a pending network request tracker to measure how much time it takes a remote peer to respond.

func New

func New(cap p2p.Cap, peerID string, timeout time.Duration) *Tracker

New creates a new network request tracker to monitor how much time it takes to fill certain requests and how individual peers perform.

func (*Tracker) Fulfil

func (t *Tracker) Fulfil(resp Response) error

Fulfil fills a pending request, if any is available, reporting on various metrics.

func (*Tracker) Stop added in v1.17.0

func (t *Tracker) Stop()

Stop reclaims resources of the tracker.

func (*Tracker) Track

func (t *Tracker) Track(req Request) error

Track adds a network request to the tracker to wait for a response to arrive or until the request it cancelled or times out.

Jump to

Keyboard shortcuts

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