connections

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnectionGater

func NewConnectionGater(logger *zap.Logger, idx peers.ConnectionIndex) connmgr.ConnectionGater

NewConnectionGater creates a new instance of ConnectionGater

Types

type ConnHandler

type ConnHandler interface {
	Handle() *libp2pnetwork.NotifyBundle
}

ConnHandler handles new connections (inbound / outbound) using libp2pnetwork.NotifyBundle

func NewConnHandler

func NewConnHandler(ctx context.Context, logger *zap.Logger, handshaker Handshaker, subnetsProvider SubnetsProvider,
	subnetsIndex peers.SubnetsIndex, connIdx peers.ConnectionIndex) ConnHandler

NewConnHandler creates a new connection handler

type HandshakeFilter

type HandshakeFilter func(info *records.NodeInfo) (bool, error)

HandshakeFilter can be used to filter nodes once we handshaked with them

func NetworkIDFilter

func NetworkIDFilter(networkID string) HandshakeFilter

NetworkIDFilter determines whether we will connect to the given node by the network ID

type Handshaker

type Handshaker interface {
	Handshake(conn libp2pnetwork.Conn) error
	Handler() libp2pnetwork.StreamHandler
}

Handshaker is the interface for handshaking with peers. it uses node info protocol to exchange information with other nodes and decide whether we want to connect.

NOTE: due to compatibility with v0, we accept nodes with user agent as a fallback when the new protocol is not supported.

func NewHandshaker

func NewHandshaker(ctx context.Context, cfg *HandshakerCfg, filters ...HandshakeFilter) Handshaker

NewHandshaker creates a new instance of handshaker

type HandshakerCfg

type HandshakerCfg struct {
	Logger          *zap.Logger
	Network         libp2pnetwork.Network
	Streams         streams.StreamController
	NodeInfoIdx     peers.NodeInfoIndex
	States          peers.NodeStates
	ConnIdx         peers.ConnectionIndex
	SubnetsIdx      peers.SubnetsIndex
	IDService       identify.IDService
	SubnetsProvider SubnetsProvider
}

HandshakerCfg is the configuration for creating an handshaker instance

type SubnetsProvider

type SubnetsProvider func() records.Subnets

SubnetsProvider returns the subnets of or node

Jump to

Keyboard shortcuts

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