stream

package
v0.32.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrGaterDisallowedConnection

func IsErrGaterDisallowedConnection(err error) bool

IsErrGaterDisallowedConnection returns whether an error is ErrGaterDisallowedConnection.

func IsErrProtocolNotSupported

func IsErrProtocolNotSupported(err error) bool

IsErrProtocolNotSupported returns whether an error is ErrProtocolNotSupported.

func IsErrSecurityProtocolNegotiationFailed

func IsErrSecurityProtocolNegotiationFailed(err error) bool

IsErrSecurityProtocolNegotiationFailed returns whether an error is ErrSecurityProtocolNegotiationFailed.

func NewLibP2PStreamFactory

func NewLibP2PStreamFactory(h host.Host) p2p.StreamFactory

Types

type ErrGaterDisallowedConnection

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

ErrGaterDisallowedConnection wrapper around github.com/libp2p/go-libp2p/p2p/net/swarm.ErrGaterDisallowedConnection.

func NewGaterDisallowedConnectionErr

func NewGaterDisallowedConnectionErr(err error) ErrGaterDisallowedConnection

NewGaterDisallowedConnectionErr returns a new ErrGaterDisallowedConnection.

func (ErrGaterDisallowedConnection) Error

type ErrProtocolNotSupported

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

ErrProtocolNotSupported indicates node is running on a different spork.

func NewProtocolNotSupportedErr

func NewProtocolNotSupportedErr(peerID peer.ID, protocolIDS []protocol.ID, err error) ErrProtocolNotSupported

NewProtocolNotSupportedErr returns a new ErrSecurityProtocolNegotiationFailed.

func (ErrProtocolNotSupported) Error

func (e ErrProtocolNotSupported) Error() string

type ErrSecurityProtocolNegotiationFailed

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

ErrSecurityProtocolNegotiationFailed indicates security protocol negotiation failed during the stream factory connect attempt.

func NewSecurityProtocolNegotiationErr

func NewSecurityProtocolNegotiationErr(pid peer.ID, err error) ErrSecurityProtocolNegotiationFailed

NewSecurityProtocolNegotiationErr returns a new ErrSecurityProtocolNegotiationFailed.

func (ErrSecurityProtocolNegotiationFailed) Error

type LibP2PStreamFactory

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

func (*LibP2PStreamFactory) Connect

func (l *LibP2PStreamFactory) Connect(ctx context.Context, peerAddrInfo peer.AddrInfo) error

Connect connects host to peer with peerAddrInfo. All errors returned from this function can be considered benign. We expect the following errors during normal operations:

  • ErrSecurityProtocolNegotiationFailed this indicates there was an issue upgrading the connection.
  • ErrGaterDisallowedConnection this indicates the connection was disallowed by the gater.
  • There may be other unexpected errors from libp2p but they should be considered benign.

func (*LibP2PStreamFactory) NewStream

func (l *LibP2PStreamFactory) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error)

NewStream creates a new stream on the libp2p host. Expected errors during normal operations:

  • ErrProtocolNotSupported this indicates remote node is running on a different spork.

func (*LibP2PStreamFactory) SetStreamHandler

func (l *LibP2PStreamFactory) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)

type PlainStream added in v0.32.2

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

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

func NewPlainStream added in v0.32.2

func NewPlainStream(handler libp2pnet.StreamHandler, protocolId protocol.ID) PlainStream

NewPlainStream creates a new PlainStream. Args: - handler: the stream handler that handles the input stream. - protocolId: the protocol id of the stream. Returns:

  • PlainStream instance.

func (PlainStream) Handler added in v0.32.2

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

func (PlainStream) ProtocolId added in v0.32.2

func (p PlainStream) ProtocolId() protocol.ID

func (PlainStream) UpgradeRawStream added in v0.32.2

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

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

Jump to

Keyboard shortcuts

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