network

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0, MIT Imports: 12 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProtocolDataTransfer is the protocol identifier for graphsync messages
	ProtocolDataTransfer protocol.ID = "/fil/datatransfer/1.0.0"
)

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

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

DataTransferNetwork provides network connectivity for GraphSync.

func NewFromLibp2pHost

func NewFromLibp2pHost(host host.Host) DataTransferNetwork

NewFromLibp2pHost returns a GraphSyncNetwork supported by underlying Libp2p host.

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)

	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