network

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProtocolBitswapOne is the prefix for the legacy bitswap protocol
	ProtocolBitswapOne protocol.ID = "/ipfs/bitswap/1.0.0"
	// ProtocolBitswapNoVers is equivalent to the legacy bitswap protocol
	ProtocolBitswapNoVers protocol.ID = "/ipfs/bitswap"

	// ProtocolBitswap is the current version of bitswap protocol, 1.1.0
	ProtocolBitswap protocol.ID = "/ipfs/bitswap/1.1.0"
)

Functions

This section is empty.

Types

type BitSwapNetwork

type BitSwapNetwork interface {

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

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

	ConnectTo(context.Context, peer.ID) error

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

	ConnectionManager() connmgr.ConnManager

	Stats() Stats

	Routing
}

BitSwapNetwork provides network connectivity for BitSwap sessions.

func NewFromIpfsHost

func NewFromIpfsHost(host host.Host, r routing.ContentRouting, opts ...NetOpt) BitSwapNetwork

NewFromIpfsHost returns a BitSwapNetwork supported by underlying IPFS host.

type MessageSender

type MessageSender interface {
	SendMsg(context.Context, bsmsg.BitSwapMessage) error
	Close() error
	Reset() error
}

MessageSender is an interface for sending a series of messages over the bitswap network

type NetOpt

type NetOpt func(*Settings)

func Prefix

func Prefix(prefix protocol.ID) NetOpt

type Receiver

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

	ReceiveError(error)

	// Connected/Disconnected warns bitswap about peer connections.
	PeerConnected(peer.ID)
	PeerDisconnected(peer.ID)
}

Receiver is an interface that can receive messages from the BitSwapNetwork.

type Routing

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

	// Provide provides the key to the network.
	Provide(context.Context, cid.Cid) error
}

Routing is an interface to providing and finding providers on a bitswap network.

type Settings

type Settings struct {
	ProtocolPrefix protocol.ID
}

type Stats

type Stats struct {
	MessagesSent  uint64
	MessagesRecvd uint64
}

Stats is a container for statistics about the bitswap network the numbers inside are specific to bitswap, and not any other protocols using the same underlying network.

Jump to

Keyboard shortcuts

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