manualpeering

package
v1.0.0-beta.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

func NewManager(networkManager network.Manager, logger log.Logger) *Manager

NewManager initializes a new Manager instance.

func (*Manager) AddPeer

func (m *Manager) AddPeer(multiAddr multiaddr.Multiaddr) (*network.Peer, error)

func (*Manager) GetPeers

func (m *Manager) GetPeers(onlyConnected ...bool) []*network.Peer

GetPeers returns the list of known peers.

func (*Manager) IsPeerKnown

func (m *Manager) IsPeerKnown(id peer.ID) bool

func (*Manager) Peer

func (m *Manager) Peer(peerID peer.ID) (*network.Peer, error)

func (*Manager) RemovePeer

func (m *Manager) RemovePeer(peerID peer.ID) error

RemovePeer removes a peer from the list of known peers.

func (*Manager) Start

func (m *Manager) Start()

Start subscribes to the gossip layer events and starts internal background workers. Calling multiple times has no effect.

func (*Manager) Stop

func (m *Manager) Stop() (err error)

Stop terminates internal background workers. Calling multiple times has no effect.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL