network

package
v0.0.0-...-e4696f9 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 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 BitSwapNetwork

type BitSwapNetwork 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)
}

BitSwapNetwork provides network connectivity for BitSwap sessions

func NewFromIpfsNetwork

func NewFromIpfsNetwork(s inet.Service, dialer inet.Dialer) BitSwapNetwork

NewFromIpfsNetwork returns a BitSwapNetwork supported by underlying IPFS Dialer & Service

type Receiver

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

	ReceiveError(error)
}

Implement Receiver to receive messages from the BitSwapNetwork

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
}

Jump to

Keyboard shortcuts

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