peermanager

package
v0.0.0-...-15711b3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2019 License: MIT, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerManager

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

PeerManager manages a pool of peers and sends messages to peers in the pool.

func New

func New(ctx context.Context, createPeerQueue PeerQueueFactory) *PeerManager

New creates a new PeerManager, given a context and a peerQueueFactory.

func (*PeerManager) Connected

func (pm *PeerManager) Connected(p peer.ID, initialEntries []*wantlist.Entry)

Connected is called to add a new peer to the pool, and send it an initial set of wants.

func (*PeerManager) ConnectedPeers

func (pm *PeerManager) ConnectedPeers() []peer.ID

ConnectedPeers returns a list of peers this PeerManager is managing.

func (*PeerManager) Disconnected

func (pm *PeerManager) Disconnected(p peer.ID)

Disconnected is called to remove a peer from the pool.

func (*PeerManager) SendMessage

func (pm *PeerManager) SendMessage(entries []*bsmsg.Entry, targets []peer.ID, from uint64)

SendMessage is called to send a message to all or some peers in the pool; if targets is nil, it sends to all.

func (*PeerManager) Shutdown

func (pm *PeerManager) Shutdown()

Shutdown shutsdown processing for the PeerManager.

func (*PeerManager) Startup

func (pm *PeerManager) Startup()

Startup enables the run loop for the PeerManager - no processing will occur if startup is not called.

type PeerQueue

type PeerQueue interface {
	RefIncrement()
	RefDecrement() bool
	AddMessage(entries []*bsmsg.Entry, ses uint64)
	Startup(ctx context.Context, initialEntries []*wantlist.Entry)
	Shutdown()
}

PeerQueue provides a queer of messages to be sent for a single peer.

type PeerQueueFactory

type PeerQueueFactory func(p peer.ID) PeerQueue

PeerQueueFactory provides a function that will create a PeerQueue.

Jump to

Keyboard shortcuts

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