Documentation ¶
Index ¶
- Constants
- type Peer
- type PeerSet
- func (ps *PeerSet) Clear()
- func (ps *PeerSet) CloseSession(id int)
- func (ps *PeerSet) FindSession(id int) *Session
- func (ps *PeerSet) GetPeer(pid peer.ID) Peer
- func (ps *PeerSet) GetPeerList() []Peer
- func (ps *PeerSet) GetRandomPeer() Peer
- func (ps *PeerSet) HasAnyOpenSession() bool
- func (ps *PeerSet) HasOpenSession(pid peer.ID) bool
- func (ps *PeerSet) IncreaseInvalidBundlesCounter(pid peer.ID)
- func (ps *PeerSet) IncreaseReceivedBundlesCounter(pid peer.ID)
- func (ps *PeerSet) IncreaseReceivedBytesCounter(pid peer.ID, c int)
- func (ps *PeerSet) IncreaseSendFailedCounter(pid peer.ID)
- func (ps *PeerSet) IncreaseSendSuccessCounter(pid peer.ID)
- func (ps *PeerSet) Len() int
- func (ps *PeerSet) MaxClaimedHeight() uint32
- func (ps *PeerSet) NumberOfOpenSessions() int
- func (ps *PeerSet) OpenSession(pid peer.ID) *Session
- func (ps *PeerSet) RemovePeer(pid peer.ID)
- func (ps *PeerSet) UpdateHeight(pid peer.ID, height uint32)
- func (ps *PeerSet) UpdateLastSeen(pid peer.ID)
- func (ps *PeerSet) UpdatePeerInfo(pid peer.ID, status StatusCode, moniker string, agent string, ...)
- func (ps *PeerSet) UpdateStatus(pid peer.ID, status StatusCode)
- type Session
- type StatusCode
Constants ¶
View Source
const ( StatusCodeBanned = StatusCode(-1) StatusCodeUnknown = StatusCode(0) StatusCodeKnown = StatusCode(1) StatusCodeTrusty = StatusCode(2) )
View Source
const (
PeerFlagNodeNetwork = 0x01
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Peer ¶
type Peer struct { Status StatusCode Moniker string Agent string PeerID peer.ID ConsensusKeys map[bls.PublicKey]bool Flags int LastSeen time.Time Height uint32 ReceivedBundles int InvalidBundles int ReceivedBytes int SendSuccess int SendFailed int }
func (*Peer) IsKnownOrTrusty ¶
func (*Peer) IsNodeNetwork ¶
type PeerSet ¶
type PeerSet struct {
// contains filtered or unexported fields
}
func NewPeerSet ¶
func (*PeerSet) CloseSession ¶
func (*PeerSet) FindSession ¶
func (*PeerSet) GetPeerList ¶
func (*PeerSet) GetRandomPeer ¶
GetRandomPeer selects a random peer from the peer set based on their weights. The weight of each peer is determined by the difference between the number of successful and failed send attempts. Peers with higher weights are more likely to be selected. TODO: can this code be better?
func (*PeerSet) HasAnyOpenSession ¶
func (*PeerSet) HasOpenSession ¶ added in v0.11.0
func (*PeerSet) IncreaseInvalidBundlesCounter ¶
func (*PeerSet) IncreaseReceivedBundlesCounter ¶
func (*PeerSet) IncreaseReceivedBytesCounter ¶
func (*PeerSet) IncreaseSendFailedCounter ¶ added in v0.11.0
func (*PeerSet) IncreaseSendSuccessCounter ¶ added in v0.11.0
func (*PeerSet) MaxClaimedHeight ¶
MaxClaimedHeight returns the maximum claimed height.
Note: This value might not be accurate. A bad peer can claim invalid height.
func (*PeerSet) NumberOfOpenSessions ¶
func (*PeerSet) RemovePeer ¶
func (*PeerSet) UpdateLastSeen ¶
func (*PeerSet) UpdatePeerInfo ¶
func (*PeerSet) UpdateStatus ¶
func (ps *PeerSet) UpdateStatus(pid peer.ID, status StatusCode)
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func (*Session) LastActivityAt ¶
func (*Session) SetLastResponseCode ¶
func (s *Session) SetLastResponseCode(code message.ResponseCode)
type StatusCode ¶
type StatusCode int
func (StatusCode) String ¶
func (code StatusCode) String() string
Click to show internal directories.
Click to hide internal directories.