network

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: Apache-2.0, MIT Imports: 9 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 deal-stream.go - implements the `RetrievalDealStream` interface, a data stream for retrieval deal traffic only 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 RetrievalDealStream

type RetrievalDealStream interface {
	ReadDealProposal() (retrievalmarket.DealProposal, error)
	WriteDealProposal(retrievalmarket.DealProposal) error
	ReadDealResponse() (retrievalmarket.DealResponse, error)
	WriteDealResponse(retrievalmarket.DealResponse) error
	ReadDealPayment() (retrievalmarket.DealPayment, error)
	WriteDealPayment(retrievalmarket.DealPayment) error
	Receiver() peer.ID
	Close() error
}

RetrievalDealStream is the API needed to send and receive retrieval deal data over data-transfer network.

type RetrievalMarketNetwork

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

	//  NewDealStream creates a new RetrievalDealStream implementer using the provided peer.ID
	NewDealStream(peer.ID) (RetrievalDealStream, 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
}

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

func NewFromLibp2pHost

func NewFromLibp2pHost(h host.Host) 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
}

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)

	// HandleDealStream sends and receives data-transfer data via the
	// RetrievalDealStream provided
	HandleDealStream(RetrievalDealStream)
}

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