Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeerHandler ¶
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 ¶
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) 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