network

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0, MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProtocolGraphsync is the protocol identifier for graphsync messages
	ProtocolGraphsync protocol.ID = "/dms3/graphsync/1.0.0"
)

Functions

This section is empty.

Types

type GraphSyncNetwork

type GraphSyncNetwork interface {

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

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

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

	NewMessageSender(context.Context, peer.ID) (MessageSender, error)
}

GraphSyncNetwork provides network connectivity for GraphSync.

func NewFromP2pHost

func NewFromP2pHost(host host.Host) GraphSyncNetwork

NewFromP2pHost returns a GraphSyncNetwork supported by underlying P2p host.

type MessageSender

type MessageSender interface {
	SendMsg(context.Context, gsmsg.GraphSyncMessage) error
	Close() error
	Reset() error
}

MessageSender is an interface to send messages to a peer

type Receiver

type Receiver interface {
	ReceiveMessage(
		ctx context.Context,
		sender peer.ID,
		incoming gsmsg.GraphSyncMessage)

	ReceiveError(p peer.ID, err error)

	Connected(p peer.ID)
	Disconnected(p peer.ID)
}

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