connectionMonitor

package
v1.0.115 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DurationBetweenReconnectAttempts = time.Second * 5

DurationBetweenReconnectAttempts is used as to not call reconnecter.ReconnectToNetwork() too often when there are a lot of peers disconnecting and reconnection to initial nodes succeeds

Functions

func NewLibp2pConnectionMonitor

func NewLibp2pConnectionMonitor(
	reconnecter p2p.ReconnecterWithPauseResumeAndWatchdog,
	thresholdMinConnectedPeers int,
	targetConnCount int,
	sharder ns.Sharder,
) (*libp2pConnectionMonitor, error)

NewLibp2pConnectionMonitor creates a new connection monitor (version 1 that calls pause and resume on the discovery process)

func NewLibp2pConnectionMonitorSimple

func NewLibp2pConnectionMonitorSimple(
	reconnecter p2p.Reconnecter,
	thresholdMinConnectedPeers int,
	sharder Sharder,
) (*libp2pConnectionMonitorSimple, error)

NewLibp2pConnectionMonitorSimple creates a new connection monitor (version 2 that is more streamlined and does not care about pausing and resuming the discovery process)

Types

type NilConnectionMonitor

type NilConnectionMonitor struct {
	// contains filtered or unexported fields
}

NilConnectionMonitor does not monitor the connections made by the host

func (*NilConnectionMonitor) ClosedStream

ClosedStream is called when a stream closed

func (*NilConnectionMonitor) Connected

Connected is called when a connection opened

func (*NilConnectionMonitor) Disconnected

func (n *NilConnectionMonitor) Disconnected(network.Network, network.Conn)

Disconnected is called when a connection closed

func (*NilConnectionMonitor) IsConnectedToTheNetwork

func (n *NilConnectionMonitor) IsConnectedToTheNetwork(netw network.Network) bool

IsConnectedToTheNetwork returns true if the number of connected peer is at least equal with thresholdMinConnectedPeers

func (*NilConnectionMonitor) IsInterfaceNil

func (n *NilConnectionMonitor) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*NilConnectionMonitor) Listen

func (n *NilConnectionMonitor) Listen(network.Network, multiaddr.Multiaddr)

Listen is called when network starts listening on an addr

func (*NilConnectionMonitor) ListenClose

func (n *NilConnectionMonitor) ListenClose(network.Network, multiaddr.Multiaddr)

ListenClose is called when network stops listening on an addr

func (*NilConnectionMonitor) OpenedStream

OpenedStream is called when a stream opened

func (*NilConnectionMonitor) SetThresholdMinConnectedPeers

func (n *NilConnectionMonitor) SetThresholdMinConnectedPeers(thresholdMinConnectedPeers int, _ network.Network)

SetThresholdMinConnectedPeers sets the minimum connected peers number when the node is considered connected on the network

func (*NilConnectionMonitor) ThresholdMinConnectedPeers

func (n *NilConnectionMonitor) ThresholdMinConnectedPeers() int

ThresholdMinConnectedPeers returns the minimum connected peers number when the node is considered connected on the network

type Sharder

type Sharder interface {
	ComputeEvictionList(pidList []peer.ID) []peer.ID
	Has(pid peer.ID, list []peer.ID) bool
	IsInterfaceNil() bool
}

Sharder defines the eviction computing process of unwanted peers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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