github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/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/onflow/flow-go/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  	RateLimiterConsumer
    23  
    24  	// RequestPeerUpdate requests an update to the peer connections of this node.
    25  	// If a peer update has already been requested (either as a periodic request or an on-demand
    26  	// request) and is outstanding, then this call is a no-op.
    27  	RequestPeerUpdate()
    28  
    29  	// ForceUpdatePeers initiates an update to the peer connections of this node immediately
    30  	ForceUpdatePeers(context.Context)
    31  
    32  	// SetPeersProvider sets the peer managers's peers provider and may be called at most once
    33  	SetPeersProvider(PeersProvider)
    34  }