peers

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

type Peer p2pcrypto.PublicKey

Peer is represented by a p2p identity public key.

type PeerSubscriptionProvider

type PeerSubscriptionProvider interface {
	SubscribePeerEvents() (conn, disc chan p2pcrypto.PublicKey)
}

PeerSubscriptionProvider is the interface that provides us with peer events channels.

type Peers

type Peers struct {
	log.Log
	// contains filtered or unexported fields
}

Peers is used by protocols to manage available peers.

func NewPeers

func NewPeers(s PeerSubscriptionProvider, lg log.Log) *Peers

NewPeers creates a Peers instance that is registered to `s`'s events and updates with them.

func NewPeersImpl

func NewPeersImpl(snapshot *atomic.Value, exit chan struct{}, lg log.Log) *Peers

NewPeersImpl creates a Peers using specified parameters and returns it

func (*Peers) Close

func (p *Peers) Close()

Close stops listening for events.

func (*Peers) GetPeers

func (p *Peers) GetPeers() []Peer

GetPeers returns a snapshot of the connected peers shuffled. Method is not concurrent-safe.

func (*Peers) PeerCount

func (p *Peers) PeerCount() uint64

PeerCount returns the number of connected peers.

Jump to

Keyboard shortcuts

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