peers

package
v1.7.0-citest.0-nomain Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerStats added in v1.4.0

type PeerStats struct {
	ID       peer.ID
	Success  int
	Failures int
	Latency  time.Duration
}

func (*PeerStats) MarshalLogObject added in v1.4.0

func (p *PeerStats) MarshalLogObject(enc zapcore.ObjectEncoder) error

type Peers

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

func New

func New() *Peers

func (*Peers) Add

func (p *Peers) Add(id peer.ID) bool

func (*Peers) Delete

func (p *Peers) Delete(id peer.ID)

func (*Peers) OnFailure

func (p *Peers) OnFailure(id peer.ID, size int, latency time.Duration)

func (*Peers) OnLatency

func (p *Peers) OnLatency(id peer.ID, size int, latency time.Duration)

OnLatency updates average peer and global latency.

func (*Peers) SelectBest

func (p *Peers) SelectBest(n int) []peer.ID

SelectBest selects at most n peers sorted by responsiveness and latency.

SelectBest parametrized by N because sync protocol relies on receiving data from redundant connections to guarantee that it will get complete data set. If it doesn't get complete data set it will have to fallback into hash resolution, which is generally more expensive.

func (*Peers) SelectBestFrom

func (p *Peers) SelectBestFrom(peers []peer.ID) peer.ID

SelectBest peer with preferences.

func (*Peers) Stats added in v1.4.0

func (p *Peers) Stats() Stats

func (*Peers) Total

func (p *Peers) Total() int

type Stats added in v1.4.0

type Stats struct {
	Total                int
	GlobalAverageLatency time.Duration
	BestPeers            []PeerStats
}

func (*Stats) MarshalLogObject added in v1.4.0

func (s *Stats) MarshalLogObject(enc zapcore.ObjectEncoder) error

Jump to

Keyboard shortcuts

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