network

package
v1.28.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0, MIT Imports: 12 Imported by: 12

Documentation

Overview

Package network providers an abstraction over a libp2p host for managing retrieval's Libp2p protocols:

network.go - defines the interfaces that must be implemented to serve as a retrieval network query_stream.go - implements the `RetrievalQueryStream` interface, a data stream for retrieval query traffic only libp2p_impl.go - provides the production implementation of the `RetrievalMarketNetwork` interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v0.6.1

type Option func(*libp2pRetrievalMarketNetwork)

Option is an option for configuring the libp2p storage market network

func RetryParameters added in v0.6.1

func RetryParameters(minDuration time.Duration, maxDuration time.Duration, attempts float64, backoffFactor float64) Option

RetryParameters changes the default parameters around connection reopening

func SupportedProtocols added in v0.7.0

func SupportedProtocols(supportedProtocols []protocol.ID) Option

SupportedProtocols sets what protocols this network instances listens on

type RetrievalMarketNetwork

type RetrievalMarketNetwork interface {
	//  NewQueryStream creates a new RetrievalQueryStream implementer using the provided peer.ID
	NewQueryStream(peer.ID) (RetrievalQueryStream, error)

	// SetDelegate sets a RetrievalReceiver implementer to handle stream data
	SetDelegate(RetrievalReceiver) error

	// StopHandlingRequests unsets the RetrievalReceiver and would perform any other necessary
	// shutdown logic.
	StopHandlingRequests() error

	// ID returns the peer id of the host for this network
	ID() peer.ID

	// AddAddrs adds the given multi-addrs to the peerstore for the passed peer ID
	AddAddrs(peer.ID, []ma.Multiaddr)
}

RetrievalMarketNetwork is the API for creating query and deal streams and delegating responders to those streams.

func NewFromLibp2pHost

func NewFromLibp2pHost(h host.Host, options ...Option) RetrievalMarketNetwork

NewFromLibp2pHost constructs a new instance of the RetrievalMarketNetwork from a libp2p host

type RetrievalQueryStream

type RetrievalQueryStream interface {
	ReadQuery() (retrievalmarket.Query, error)
	WriteQuery(retrievalmarket.Query) error
	ReadQueryResponse() (retrievalmarket.QueryResponse, error)
	WriteQueryResponse(retrievalmarket.QueryResponse) error
	Close() error
	RemotePeer() peer.ID
}

RetrievalQueryStream is the API needed to send and receive retrieval query data over data-transfer network.

type RetrievalReceiver

type RetrievalReceiver interface {
	// HandleQueryStream sends and receives data-transfer data via the
	// RetrievalQueryStream provided
	HandleQueryStream(RetrievalQueryStream)
}

RetrievalReceiver is the API for handling data coming in on both query and deal streams

Jump to

Keyboard shortcuts

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