Documentation ¶
Index ¶
- type PeerTagger
- type SessionPeerManager
- func (spm *SessionPeerManager) AddPeer(p peer.ID) bool
- func (spm *SessionPeerManager) HasPeer(p peer.ID) bool
- func (spm *SessionPeerManager) HasPeers() bool
- func (spm *SessionPeerManager) Peers() []peer.ID
- func (spm *SessionPeerManager) PeersDiscovered() bool
- func (spm *SessionPeerManager) ProtectConnection(p peer.ID)
- func (spm *SessionPeerManager) RemovePeer(p peer.ID) bool
- func (spm *SessionPeerManager) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeerTagger ¶
type PeerTagger interface { TagPeer(peer.ID, string, int) UntagPeer(p peer.ID, tag string) Protect(peer.ID, string) Unprotect(peer.ID, string) bool }
PeerTagger is an interface for tagging peers with metadata
type SessionPeerManager ¶
type SessionPeerManager struct {
// contains filtered or unexported fields
}
SessionPeerManager keeps track of peers for a session, and takes care of ConnectionManager tagging.
func New ¶
func New(id uint64, tagger PeerTagger) *SessionPeerManager
New creates a new SessionPeerManager
func (*SessionPeerManager) AddPeer ¶
func (spm *SessionPeerManager) AddPeer(p peer.ID) bool
AddPeer adds the peer to the SessionPeerManager. Returns true if the peer is a new peer, false if it already existed.
func (*SessionPeerManager) HasPeers ¶
func (spm *SessionPeerManager) HasPeers() bool
func (*SessionPeerManager) Peers ¶
func (spm *SessionPeerManager) Peers() []peer.ID
func (*SessionPeerManager) PeersDiscovered ¶
func (spm *SessionPeerManager) PeersDiscovered() bool
PeersDiscovered indicates whether peers have been discovered yet. Returns true once a peer has been discovered by the session (even if all peers are later removed from the session).
func (*SessionPeerManager) ProtectConnection ¶
func (spm *SessionPeerManager) ProtectConnection(p peer.ID)
Protect connection to this peer from being pruned by the connection manager
func (*SessionPeerManager) RemovePeer ¶
func (spm *SessionPeerManager) RemovePeer(p peer.ID) bool
RemovePeer removes the peer from the SessionPeerManager. Returns true if the peer was removed, false if it did not exist.
func (*SessionPeerManager) Shutdown ¶
func (spm *SessionPeerManager) Shutdown()
Shutdown untags all the peers