connections

package
v0.0.0-...-420b085 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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, 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

type Handshaker

type Handshaker interface {
	Handshake(logger *zap.Logger, conn libp2pnetwork.Conn) error
	Handler(logger *zap.Logger) 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, db *db.BoltDB, geoData *geodata.GeoIP2DB) 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
	IDService   identify.IDService
}

HandshakerCfg is the configuration for creating an handshaker instance

Jump to

Keyboard shortcuts

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