peermanager

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0, MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerHandler added in v0.6.0

type PeerHandler interface{}

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

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) AllocateAndBuildMessage added in v0.6.0

func (pmm *PeerMessageManager) AllocateAndBuildMessage(p peer.ID, blkSize uint64, buildMessageFn func(*messagequeue.Builder))

BuildMessage allows you to modify the next message that is sent for the given peer If blkSize > 0, message building may block until enough memory has been freed from the queues to allocate the message.

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, onShutdown func(peer.ID)) PeerHandler

PeerProcessFactory provides a function that will create a PeerQueue.

type PeerQueue

type PeerQueue interface {
	PeerProcess
	AllocateAndBuildMessage(blkSize uint64, buildMessageFn func(*messagequeue.Builder))
}

PeerQueue is a process that sends messages to a peer

type PeerQueueFactory

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