peers

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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)

func (*Peers) Delete

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

func (*Peers) OnFailure

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

func (*Peers) OnLatency

func (p *Peers) OnLatency(id peer.ID, 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) Total

func (p *Peers) Total() int

Jump to

Keyboard shortcuts

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