Documentation ¶
Index ¶
- type PeerStats
- type Peers
- func (p *Peers) Add(id peer.ID, protocols func() []protocol.ID) bool
- func (p *Peers) Contains(id peer.ID) bool
- func (p *Peers) Delete(id peer.ID)
- func (p *Peers) OnFailure(id peer.ID, size int, latency time.Duration)
- func (p *Peers) OnLatency(id peer.ID, size int, latency time.Duration)
- func (p *Peers) SelectBest(n int) []peer.ID
- func (p *Peers) SelectBestFrom(peers []peer.ID) peer.ID
- func (p *Peers) SelectBestWithProtocols(n int, protocols []protocol.ID) []peer.ID
- func (p *Peers) Stats() Stats
- func (p *Peers) Total() int
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeerStats ¶ added in v1.4.0
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 (*Peers) SelectBest ¶
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 ¶
SelectBest peer with preferences.
func (*Peers) SelectBestWithProtocols ¶ added in v1.7.8
SelectBestWithProtocols is similar to SelectBest but filters peers by supported protocols. If protocols is empty, it returns the best peers regardless of the protocol. If protocols is not empty, it returns the best peers that support at least one of the protocols.