github.com/koko1123/flow-go-1@v0.29.6/network/p2p/peerManager.go (about)

     1  package p2p
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/libp2p/go-libp2p/core/host"
     7  	"github.com/libp2p/go-libp2p/core/peer"
     8  	"github.com/rs/zerolog"
     9  
    10  	"github.com/koko1123/flow-go-1/module/component"
    11  )
    12  
    13  // PeerManagerFactoryFunc is a factory function type for generating a PeerManager instance using the given host,
    14  // peersProvider and logger
    15  type PeerManagerFactoryFunc func(host host.Host, peersProvider PeersProvider, logger zerolog.Logger) (PeerManager, error)
    16  
    17  type PeersProvider func() peer.IDSlice
    18  
    19  // PeerManager adds and removes connections to peers periodically and on request
    20  type PeerManager interface {
    21  	component.Component
    22  
    23  	// RequestPeerUpdate requests an update to the peer connections of this node.
    24  	// If a peer update has already been requested (either as a periodic request or an on-demand
    25  	// request) and is outstanding, then this call is a no-op.
    26  	RequestPeerUpdate()
    27  
    28  	// ForceUpdatePeers initiates an update to the peer connections of this node immediately
    29  	ForceUpdatePeers(context.Context)
    30  
    31  	// SetPeersProvider sets the peer managers's peers provider and may be called at most once
    32  	SetPeersProvider(PeersProvider)
    33  }