network

package
v0.0.0-...-c9e5fdf Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2014 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {

	// DialPeer ensures there is a connection to peer.
	DialPeer(context.Context, peer.Peer) error

	// SendMessage sends a BitSwap message to a peer.
	SendMessage(
		context.Context,
		peer.Peer,
		bsmsg.BitSwapMessage) error

	// SendRequest sends a BitSwap message to a peer and waits for a response.
	SendRequest(
		context.Context,
		peer.Peer,
		bsmsg.BitSwapMessage) (incoming bsmsg.BitSwapMessage, err error)

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

Adapter provides network connectivity for BitSwap sessions

func NetMessageAdapter

func NetMessageAdapter(s inet.Service, n inet.Network, r Receiver) Adapter

NetMessageAdapter wraps a NetMessage network service

type Receiver

type Receiver interface {
	ReceiveMessage(
		ctx context.Context, sender peer.Peer, incoming bsmsg.BitSwapMessage) (
		destination peer.Peer, outgoing bsmsg.BitSwapMessage)

	ReceiveError(error)
}

type Routing

type Routing interface {
	// FindProvidersAsync returns a channel of providers for the given key
	FindProvidersAsync(context.Context, u.Key, int) <-chan peer.Peer

	// Provide provides the key to the network
	Provide(context.Context, u.Key) error
}

TODO rename -> Router?

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳