peermanager

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 4 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, initialWants *wantlist.SessionTrackedWantlist)

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.

type PeerQueue

type PeerQueue interface {
	AddMessage(entries []bsmsg.Entry, ses uint64)
	//AddTicketMessage(tickets []tickets.Ticket, ses uint64)
	//AddTicketAckMessage(acks []tickets.TicketAck, ses uint64)
	Startup()
	AddWantlist(initialWants *wantlist.SessionTrackedWantlist)
	Shutdown()
}

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

type PeerQueueFactory

type PeerQueueFactory func(ctx context.Context, 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