Documentation ¶
Index ¶
- type GetPeersConfig
- type GetPeersOption
- type Manager
- func (m *Manager) AddPeers(peerAddrs ...multiaddr.Multiaddr) error
- func (m *Manager) GetPeers(opts ...GetPeersOption) []*network.PeerDescriptor
- func (m *Manager) IsPeerKnown(id peer.ID) bool
- func (m *Manager) RemovePeer(peerID peer.ID) error
- func (m *Manager) Start()
- func (m *Manager) Stop() (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GetPeersConfig ¶
type GetPeersConfig struct { // If true, GetPeers returns peers that have actual connection established in the gossip layer. OnlyConnected bool `json:"onlyConnected"` }
GetPeersConfig holds optional parameters for the GetPeers method.
func BuildGetPeersConfig ¶
func BuildGetPeersConfig(opts []GetPeersOption) *GetPeersConfig
BuildGetPeersConfig builds GetPeersConfig struct from a list of options.
func (*GetPeersConfig) ToOptions ¶
func (c *GetPeersConfig) ToOptions() (opts []GetPeersOption)
ToOptions translates config struct to a list of corresponding options.
type GetPeersOption ¶
type GetPeersOption func(conf *GetPeersConfig)
GetPeersOption defines a single option for GetPeers method.
func WithOnlyConnectedPeers ¶
func WithOnlyConnectedPeers() GetPeersOption
WithOnlyConnectedPeers returns a GetPeersOption that sets OnlyConnected field to true.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the core entity in the manual peering package. It holds a list of known peers and constantly provisions it to the gossip layer. Its job is to keep in sync the list of known peers and the list of current manual neighbors connected in the gossip layer. If a new peer is added to known peers, manager will forward it to gossip and make sure it establishes a connection. And vice versa, if a peer is being removed from the list of known peers, manager will make sure gossip drops that connection. Manager also subscribes to the gossip events and in case the connection with a manual peer fails it will reconnect.
func NewManager ¶
NewManager initializes a new Manager instance.
func (*Manager) GetPeers ¶
func (m *Manager) GetPeers(opts ...GetPeersOption) []*network.PeerDescriptor
GetPeers returns the list of known peers.
func (*Manager) RemovePeer ¶
RemovePeer removes a peer from the list of known peers.