unicast

package
v0.31.13-compress-badg... Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: AGPL-3.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// MaxRetryJitter is the maximum number of milliseconds to wait between attempts for a 1-1 direct connection
	MaxRetryJitter = 5

	// DefaultRetryDelay Initial delay between failing to establish a connection with another node and retrying. This delay
	// increases exponentially (exponential backoff) with the number of subsequent failures to establish a connection.
	DefaultRetryDelay = 1 * time.Second
)

Variables

This section is empty.

Functions

func IsErrDialInProgress added in v0.30.0

func IsErrDialInProgress(err error) bool

IsErrDialInProgress returns whether an error is ErrDialInProgress

func IsErrMaxRetries added in v0.30.0

func IsErrMaxRetries(err error) bool

IsErrMaxRetries returns whether an error is ErrMaxRetries.

Types

type ErrDialInProgress added in v0.30.0

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

ErrDialInProgress indicates that the libp2p node is currently dialing the peer.

func NewDialInProgressErr added in v0.30.0

func NewDialInProgressErr(pid peer.ID) ErrDialInProgress

NewDialInProgressErr returns a new ErrDialInProgress.

func (ErrDialInProgress) Error added in v0.30.0

func (e ErrDialInProgress) Error() string

type ErrMaxRetries added in v0.30.0

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

ErrMaxRetries indicates retries completed with max retries without a successful attempt.

func NewMaxRetriesErr added in v0.30.0

func NewMaxRetriesErr(attempts uint64, err error) ErrMaxRetries

NewMaxRetriesErr returns a new ErrMaxRetries.

func (ErrMaxRetries) Error added in v0.30.0

func (e ErrMaxRetries) Error() string

type Manager

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

Manager manages libp2p stream negotiation and creation, which is utilized for unicast dispatches.

func NewUnicastManager

func NewUnicastManager(logger zerolog.Logger,
	streamFactory stream.Factory,
	sporkId flow.Identifier,
	createStreamRetryDelay time.Duration,
	connStatus p2p.PeerConnections,
	metrics module.UnicastManagerMetrics,
) *Manager

func (*Manager) CreateStream

func (m *Manager) CreateStream(ctx context.Context, peerID peer.ID, maxAttempts int) (libp2pnet.Stream, []multiaddr.Multiaddr, error)

CreateStream tries establishing a libp2p stream to the remote peer id. It tries creating streams in the descending order of preference until it either creates a successful stream or runs out of options. Creating stream on each protocol is tried at most `maxAttempts`, and then falls back to the less preferred one.

func (*Manager) Register

func (m *Manager) Register(protocol protocols.ProtocolName) error

Register registers given protocol name as preferred unicast. Each invocation of register prioritizes the current protocol over previously registered ones.

func (*Manager) WithDefaultHandler

func (m *Manager) WithDefaultHandler(defaultHandler libp2pnet.StreamHandler)

WithDefaultHandler sets the default stream handler for this unicast manager. The default handler is utilized as the core handler for other unicast protocols, e.g., compressions.

type PlainStream

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

PlainStream is a stream factory that reflects the same input stream without any modification.

func (PlainStream) Handler

func (p PlainStream) Handler(s libp2pnet.Stream)

func (PlainStream) ProtocolId

func (p PlainStream) ProtocolId() protocol.ID

func (PlainStream) UpgradeRawStream added in v0.23.9

func (p PlainStream) UpgradeRawStream(s libp2pnet.Stream) (libp2pnet.Stream, error)

UpgradeRawStream implements protocol interface and returns the input stream without any modification.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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