peermanager

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT, Apache-2.0, 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 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 PeerProcessFactory) *PeerManager

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

func (*PeerManager) Connected

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

Connected is called to add a new peer to the pool

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) GetProcess

func (pm *PeerManager) GetProcess(
	p peer.ID) PeerProcess

GetProcess returns the process for the given peer

type PeerMessageManager

type PeerMessageManager struct {
	*PeerManager
}

PeerMessageManager manages message queues for peers

func NewMessageManager

func NewMessageManager(ctx context.Context, createPeerQueue PeerQueueFactory) *PeerMessageManager

NewMessageManager generates a new manger for sending messages

func (*PeerMessageManager) SendRequest

func (pmm *PeerMessageManager) SendRequest(p peer.ID, request gsmsg.GraphSyncRequest, notifees ...notifications.Notifee)

SendRequest sends the given GraphSyncRequest to the given peer

func (*PeerMessageManager) SendResponse

func (pmm *PeerMessageManager) SendResponse(p peer.ID,
	responses []gsmsg.GraphSyncResponse, blks []blocks.Block, notifees ...notifications.Notifee)

SendResponse sends the given GraphSyncResponses and blocks to the given peer.

type PeerProcess

type PeerProcess interface {
	Startup()
	Shutdown()
}

PeerProcess is any process that provides services for a peer

type PeerProcessFactory

type PeerProcessFactory func(ctx context.Context, p peer.ID) PeerProcess

PeerProcessFactory provides a function that will create a PeerQueue.

type PeerQueue

type PeerQueue interface {
	PeerProcess
	AddRequest(graphSyncRequest gsmsg.GraphSyncRequest, notifees ...notifications.Notifee)
	AddResponses(responses []gsmsg.GraphSyncResponse, blks []blocks.Block, notifees ...notifications.Notifee)
}

PeerQueue is a process that sends messages to a 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