peerset

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerSet

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

func NewPeerSet

func NewPeerSet(sessionTimeout time.Duration) *PeerSet

NewPeerSet constructs a new PeerSet for managing peer information.

func (*PeerSet) GetPeer

func (ps *PeerSet) GetPeer(pid peer.ID) *peer.Peer

GetPeer finds a peer by id and returns a copy of the peer object.

func (*PeerSet) GetPeerStatus added in v1.2.0

func (ps *PeerSet) GetPeerStatus(pid peer.ID) status.Status

GetPeerStatus finds a peer by id and returns the status of the Peer.

func (*PeerSet) GetRandomPeer

func (ps *PeerSet) GetRandomPeer() *peer.Peer

GetRandomPeer selects a random peer from the peer set based on their download score. Peers with higher score are more likely to be selected.

func (*PeerSet) HasAnyOpenSession

func (ps *PeerSet) HasAnyOpenSession() bool

func (*PeerSet) HasOpenSession added in v0.11.0

func (ps *PeerSet) HasOpenSession(pid peer.ID) bool

HasOpenSession checks if the specified peer has an open session for downloading blocks. Note that a peer may have more than one session.

func (*PeerSet) IteratePeers added in v0.15.0

func (ps *PeerSet) IteratePeers(consumer func(p *peer.Peer) (stop bool))

func (*PeerSet) Len

func (ps *PeerSet) Len() int

func (*PeerSet) Metric added in v1.6.0

func (ps *PeerSet) Metric() metric.Metric

func (*PeerSet) NumberOfSessions added in v0.17.0

func (ps *PeerSet) NumberOfSessions() int

NumberOfSessions returns the total number of sessions.

func (*PeerSet) OpenSession

func (ps *PeerSet) OpenSession(pid peer.ID, from, count uint32) int

OpenSession opens a new session for downloading blocks and returns the session ID.

func (*PeerSet) RemoveAllSessions added in v0.17.0

func (ps *PeerSet) RemoveAllSessions()

func (*PeerSet) RemovePeer

func (ps *PeerSet) RemovePeer(pid peer.ID)

func (*PeerSet) SessionStats added in v0.17.0

func (ps *PeerSet) SessionStats() session.Stats

func (*PeerSet) Sessions added in v1.0.2

func (ps *PeerSet) Sessions() []*session.Session

func (*PeerSet) SetExpiredSessionsAsUncompleted added in v0.17.0

func (ps *PeerSet) SetExpiredSessionsAsUncompleted()

func (*PeerSet) SetSessionCompleted added in v0.17.0

func (ps *PeerSet) SetSessionCompleted(sid int)

func (*PeerSet) SetSessionUncompleted added in v0.17.0

func (ps *PeerSet) SetSessionUncompleted(sid int)

func (*PeerSet) StartedAt added in v0.13.0

func (ps *PeerSet) StartedAt() time.Time

func (*PeerSet) TotalSentBundles added in v0.18.3

func (ps *PeerSet) TotalSentBundles() int

func (*PeerSet) UpdateAddress added in v0.17.0

func (ps *PeerSet) UpdateAddress(pid peer.ID, addr, direction string)

func (*PeerSet) UpdateHeight

func (ps *PeerSet) UpdateHeight(pid peer.ID, height uint32, lastBlockHash hash.Hash)

func (*PeerSet) UpdateInfo added in v0.15.0

func (ps *PeerSet) UpdateInfo(
	pid peer.ID,
	moniker string,
	agent string,
	consKeys []*bls.PublicKey,
	services service.Services,
)

func (*PeerSet) UpdateInvalidMetric added in v1.6.0

func (ps *PeerSet) UpdateInvalidMetric(pid peer.ID, bytes int64)

func (*PeerSet) UpdateLastReceived added in v0.15.0

func (ps *PeerSet) UpdateLastReceived(pid peer.ID)

func (*PeerSet) UpdateLastSent added in v0.15.0

func (ps *PeerSet) UpdateLastSent(pid peer.ID)

func (*PeerSet) UpdateProtocols added in v0.18.0

func (ps *PeerSet) UpdateProtocols(pid peer.ID, protocols []string)

func (*PeerSet) UpdateReceivedMetric added in v1.6.0

func (ps *PeerSet) UpdateReceivedMetric(pid peer.ID, msgType message.Type, bytes int64)

func (*PeerSet) UpdateSentMetric added in v1.6.0

func (ps *PeerSet) UpdateSentMetric(pid *peer.ID, msgType message.Type, bytes int64)

func (*PeerSet) UpdateSessionLastActivity added in v0.18.0

func (ps *PeerSet) UpdateSessionLastActivity(sid int)

func (*PeerSet) UpdateStatus

func (ps *PeerSet) UpdateStatus(pid peer.ID, status status.Status)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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