streams

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTimeoutStream

func NewTimeoutStream(s core.Stream) network.SyncStream

NewTimeoutStream returns a new instance of stream

Types

type StreamController

type StreamController interface {
	// Request sends a message to the given stream and returns the response
	Request(peerID peer.ID, protocol protocol.ID, msg *network.Message) (*network.Message, error)
	// HandleStream is called at the beginning of stream handlers to create a wrapper stream and read first message
	HandleStream(stream core.Stream) (*network.Message, network.SyncStream, error)
	// Respond responds to incoming message
	Respond(msg *network.Message) error
}

StreamController simplifies the interaction with libp2p streams. it wraps and keeps a reference to the opened stream, then takes care of reading/writing when needed.

func NewStreamController

func NewStreamController(ctx context.Context, logger *zap.Logger, host host.Host,
	fork forks.Fork, requestTimeout time.Duration) StreamController

NewStreamController create a new instance of StreamController

Jump to

Keyboard shortcuts

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