Documentation ¶
Index ¶
- type PeerManager
- func (pm *PeerManager) Connected(p peer.ID, initialEntries []*wantlist.Entry)
- func (pm *PeerManager) ConnectedPeers() []peer.ID
- func (pm *PeerManager) Disconnected(p peer.ID)
- func (pm *PeerManager) SendMessage(entries []*bsmsg.Entry, targets []peer.ID, from uint64)
- func (pm *PeerManager) Shutdown()
- func (pm *PeerManager) Startup()
- type PeerQueue
- type PeerQueueFactory
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 ¶
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 ¶
PeerQueueFactory provides a function that will create a PeerQueue.