peerset

package
v0.18.4 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCodeBanned       = StatusCode(-1)
	StatusCodeUnknown      = StatusCode(0)
	StatusCodeDisconnected = StatusCode(1)
	StatusCodeConnected    = StatusCode(2)
	StatusCodeKnown        = StatusCode(3)
	StatusCodeTrusty       = StatusCode(4)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

type Peer struct {
	Status            StatusCode
	Moniker           string
	Agent             string
	Address           string
	Direction         string
	Protocols         []string
	PeerID            peer.ID
	ConsensusKeys     []*bls.PublicKey
	Services          service.Services
	LastSent          time.Time
	LastReceived      time.Time
	LastBlockHash     hash.Hash
	Height            uint32
	ReceivedBundles   int
	InvalidBundles    int
	TotalSessions     int
	CompletedSessions int
	ReceivedBytes     map[message.Type]int64
	SentBytes         map[message.Type]int64
}

func NewPeer

func NewPeer(peerID peer.ID) *Peer

func (*Peer) HasNetworkService added in v0.15.0

func (p *Peer) HasNetworkService() bool

func (*Peer) IsBanned

func (p *Peer) IsBanned() bool

func (*Peer) IsKnownOrTrusty

func (p *Peer) IsKnownOrTrusty() bool

type PeerSet

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

func NewPeerSet

func NewPeerSet(sessionTimeout time.Duration) *PeerSet

func (*PeerSet) FindSession

func (ps *PeerSet) FindSession(sid int) *session.Session

func (*PeerSet) GetPeer

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

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

func (*PeerSet) GetRandomPeer

func (ps *PeerSet) GetRandomPeer() *Peer

GetRandomPeer selects a random peer from the peer set based on their weights. The weight of each peer is determined by the number of failed and total bundles. Peers with higher weights 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

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(peer *Peer) (stop bool))

func (*PeerSet) IterateSessions added in v0.17.0

func (ps *PeerSet) IterateSessions(consumer func(s *session.Session) (stop bool))

func (*PeerSet) Len

func (ps *PeerSet) Len() int

func (*PeerSet) NumberOfSessions added in v0.17.0

func (ps *PeerSet) NumberOfSessions() int

func (*PeerSet) OpenSession

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

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() SessionStats

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, status StatusCode)

type SessionStats added in v0.17.0

type SessionStats struct {
	Total       int
	Open        int
	Completed   int
	Uncompleted int
}

func (*SessionStats) String added in v0.17.0

func (ss *SessionStats) String() string

type StatusCode

type StatusCode int

func (StatusCode) String

func (code StatusCode) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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