peerset

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 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) IncreaseInvalidBundlesCounter

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

func (*PeerSet) IncreaseReceivedBundlesCounter

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

func (*PeerSet) IncreaseReceivedBytesCounter

func (ps *PeerSet) IncreaseReceivedBytesCounter(pid peer.ID, msgType message.Type, c int64)

func (*PeerSet) IncreaseSentCounters added in v0.18.3

func (ps *PeerSet) IncreaseSentCounters(msgType message.Type, c int64, pid *peer.ID)

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) 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) ReceivedBytes added in v0.15.0

func (ps *PeerSet) ReceivedBytes() map[message.Type]int64

func (*PeerSet) ReceivedBytesMessageType added in v0.15.0

func (ps *PeerSet) ReceivedBytesMessageType(msgType message.Type) int64

func (*PeerSet) RemoveAllSessions added in v0.17.0

func (ps *PeerSet) RemoveAllSessions()

func (*PeerSet) RemovePeer

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

func (*PeerSet) SentBytes added in v0.15.0

func (ps *PeerSet) SentBytes() map[message.Type]int64

func (*PeerSet) SentBytesMessageType added in v0.15.0

func (ps *PeerSet) SentBytesMessageType(msgType message.Type) int64

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) TotalReceivedBytes added in v0.13.0

func (ps *PeerSet) TotalReceivedBytes() int64

func (*PeerSet) TotalSentBundles added in v0.18.3

func (ps *PeerSet) TotalSentBundles() int

func (*PeerSet) TotalSentBytes added in v0.13.0

func (ps *PeerSet) TotalSentBytes() int64

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) 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) UpdateSessionLastActivity added in v0.18.0

func (ps *PeerSet) UpdateSessionLastActivity(sid int)

func (*PeerSet) UpdateStatus

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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