network

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0, MIT Imports: 17 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataTransferNetwork

type DataTransferNetwork interface {
	Protect(id peer.ID, tag string)
	Unprotect(id peer.ID, tag string) bool

	// SendMessage sends a GraphSync message to a peer.
	SendMessage(
		context.Context,
		peer.ID,
		datatransfer.Message) error

	// SetDelegate registers the Reciver to handle messages received from the
	// network.
	SetDelegate(Receiver)

	// ConnectTo establishes a connection to the given peer
	ConnectTo(context.Context, peer.ID) error

	// ConnectWithRetry establishes a connection to the given peer, retrying if
	// necessary, and opens a stream on the data-transfer protocol to verify
	// the peer will accept messages on the protocol
	ConnectWithRetry(ctx context.Context, p peer.ID) error

	// ID returns the peer id of this libp2p host
	ID() peer.ID

	// Protocol returns the protocol version of the peer, connecting to
	// the peer if necessary
	Protocol(context.Context, peer.ID) (protocol.ID, error)
}

DataTransferNetwork provides network connectivity for GraphSync.

func NewFromLibp2pHost

func NewFromLibp2pHost(host host.Host, options ...Option) DataTransferNetwork

NewFromLibp2pHost returns a GraphSyncNetwork supported by underlying Libp2p host.

type Option added in v0.9.0

type Option func(*libp2pDataTransferNetwork)

Option is an option for configuring the libp2p storage market network

func DataTransferProtocols added in v0.9.0

func DataTransferProtocols(protocols []protocol.ID) Option

DataTransferProtocols OVERWRITES the default libp2p protocols we use for data transfer with the given protocols.

func RetryParameters added in v0.9.0

func RetryParameters(minDuration time.Duration, maxDuration time.Duration, attempts float64, backoffFactor float64) Option

RetryParameters changes the default parameters around connection reopening

func SendMessageParameters added in v1.2.7

func SendMessageParameters(openStreamTimeout time.Duration, sendMessageTimeout time.Duration) Option

SendMessageParameters changes the default parameters around sending messages

type Receiver

type Receiver interface {
	ReceiveRequest(
		ctx context.Context,
		sender peer.ID,
		incoming datatransfer.Request)

	ReceiveResponse(
		ctx context.Context,
		sender peer.ID,
		incoming datatransfer.Response)

	ReceiveRestartExistingChannelRequest(ctx context.Context, sender peer.ID, incoming datatransfer.Request)

	ReceiveError(error)
}

Receiver is an interface for receiving messages from the GraphSyncNetwork.

Jump to

Keyboard shortcuts

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