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: 25 Imported by: 26

Documentation

Overview

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

network.go - defines the interfaces that must be implemented to serve as a storage network layer deal_stream.go - implements the `StorageDealStream` interface, a data stream for proposing storage deals ask_stream.go - implements the `StorageAskStream` interface, a data stream for querying provider asks deal_status_stream.go - implements the `StorageDealStatusStream` interface, a data stream for querying for deal status libp2p_impl.go - provides the production implementation of the `StorageMarketNetwork` interface. types.go - types for messages sent on the storage market libp2p protocols

Index

Constants

View Source
const TagPriority = 100

TagPriority is the priority for deal streams -- they should generally be preserved above all else

Variables

View Source
var AskRequestUndefined = AskRequest{}

AskRequestUndefined represents and empty AskRequest message

View Source
var AskResponseUndefined = AskResponse{}

AskResponseUndefined represents an empty AskResponse message

View Source
var DealStatusRequestUndefined = DealStatusRequest{}

DealStatusRequestUndefined represents an empty DealStatusRequest message

View Source
var DealStatusResponseUndefined = DealStatusResponse{}

DealStatusResponseUndefined represents an empty DealStatusResponse message

View Source
var ProposalUndefined = Proposal{}

ProposalUndefined is an empty Proposal message

View Source
var SignedResponseUndefined = SignedResponse{}

SignedResponseUndefined represents an empty SignedResponse message

Functions

This section is empty.

Types

type AskRequest

type AskRequest struct {
	Miner address.Address
}

AskRequest is a request for current ask parameters for a given miner

func (*AskRequest) MarshalCBOR

func (t *AskRequest) MarshalCBOR(w io.Writer) error

func (*AskRequest) UnmarshalCBOR

func (t *AskRequest) UnmarshalCBOR(r io.Reader) (err error)

type AskResponse

type AskResponse struct {
	Ask *storagemarket.SignedStorageAsk
}

AskResponse is the response sent over the network in response to an ask request

func (*AskResponse) MarshalCBOR

func (t *AskResponse) MarshalCBOR(w io.Writer) error

func (*AskResponse) UnmarshalCBOR

func (t *AskResponse) UnmarshalCBOR(r io.Reader) (err error)

type DealStatusRequest added in v0.3.2

type DealStatusRequest struct {
	Proposal  cid.Cid
	Signature crypto.Signature
}

DealStatusRequest sent by a client to query deal status

func (*DealStatusRequest) MarshalCBOR added in v0.3.2

func (t *DealStatusRequest) MarshalCBOR(w io.Writer) error

func (*DealStatusRequest) UnmarshalCBOR added in v0.3.2

func (t *DealStatusRequest) UnmarshalCBOR(r io.Reader) (err error)

type DealStatusResponse added in v0.3.2

type DealStatusResponse struct {
	DealState storagemarket.ProviderDealState
	Signature crypto.Signature
}

DealStatusResponse is a provider's response to DealStatusRequest

func (*DealStatusResponse) MarshalCBOR added in v0.3.2

func (t *DealStatusResponse) MarshalCBOR(w io.Writer) error

func (*DealStatusResponse) UnmarshalCBOR added in v0.3.2

func (t *DealStatusResponse) UnmarshalCBOR(r io.Reader) (err error)

type DealStatusStream added in v0.3.2

type DealStatusStream interface {
	ReadDealStatusRequest() (DealStatusRequest, error)
	WriteDealStatusRequest(DealStatusRequest) error
	ReadDealStatusResponse() (DealStatusResponse, []byte, error)
	WriteDealStatusResponse(DealStatusResponse, ResigningFunc) error
	Close() error
}

DealStatusStream is a stream for reading and writing requests and responses on the deal status protocol

type Option added in v0.6.1

type Option func(*libp2pStorageMarketNetwork)

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 SupportedAskProtocols added in v0.7.0

func SupportedAskProtocols(supportedProtocols []protocol.ID) Option

SupportedAskProtocols sets what ask protocols this network instances listens on

func SupportedDealProtocols added in v0.7.0

func SupportedDealProtocols(supportedProtocols []protocol.ID) Option

SupportedDealProtocols sets what deal protocols this network instances listens on

func SupportedDealStatusProtocols added in v0.7.0

func SupportedDealStatusProtocols(supportedProtocols []protocol.ID) Option

SupportedDealStatusProtocols sets what deal status protocols this network instances listens on

type PeerTagger added in v0.5.5

type PeerTagger interface {
	TagPeer(peer.ID, string)
	UntagPeer(peer.ID, string)
}

PeerTagger implements arbitrary tagging of peers

type Proposal

type Proposal struct {
	DealProposal  *market.ClientDealProposal
	Piece         *storagemarket.DataRef
	FastRetrieval bool
}

Proposal is the data sent over the network from client to provider when proposing a deal

func (*Proposal) MarshalCBOR

func (t *Proposal) MarshalCBOR(w io.Writer) error

func (*Proposal) UnmarshalCBOR

func (t *Proposal) UnmarshalCBOR(r io.Reader) (err error)

type ResigningFunc added in v0.7.0

type ResigningFunc func(ctx context.Context, data interface{}) (*crypto.Signature, error)

ResigningFunc allows you to resign data as needed when downgrading a response

type Response

type Response struct {
	State storagemarket.StorageDealStatus

	// DealProposalRejected
	Message  string
	Proposal cid.Cid

	// StorageDealProposalAccepted
	PublishMessage *cid.Cid
}

Response is a response to a proposal sent over the network

func (*Response) MarshalCBOR

func (t *Response) MarshalCBOR(w io.Writer) error

func (*Response) UnmarshalCBOR

func (t *Response) UnmarshalCBOR(r io.Reader) (err error)

type SignedResponse

type SignedResponse struct {
	Response Response

	Signature *crypto.Signature
}

SignedResponse is a response that is signed

func (*SignedResponse) MarshalCBOR

func (t *SignedResponse) MarshalCBOR(w io.Writer) error

func (*SignedResponse) UnmarshalCBOR

func (t *SignedResponse) UnmarshalCBOR(r io.Reader) (err error)

type StorageAskStream

type StorageAskStream interface {
	ReadAskRequest() (AskRequest, error)
	WriteAskRequest(AskRequest) error
	ReadAskResponse() (AskResponse, []byte, error)
	WriteAskResponse(AskResponse, ResigningFunc) error
	Close() error
}

StorageAskStream is a stream for reading/writing requests & responses on the Storage Ask protocol

type StorageDealStream

type StorageDealStream interface {
	ReadDealProposal() (Proposal, error)
	WriteDealProposal(Proposal) error
	ReadDealResponse() (SignedResponse, []byte, error)
	WriteDealResponse(SignedResponse, ResigningFunc) error
	RemotePeer() peer.ID
	Close() error
}

StorageDealStream is a stream for reading and writing requests and responses on the storage deal protocol

type StorageMarketNetwork

type StorageMarketNetwork interface {
	NewAskStream(context.Context, peer.ID) (StorageAskStream, error)
	NewDealStream(context.Context, peer.ID) (StorageDealStream, error)
	NewDealStatusStream(context.Context, peer.ID) (DealStatusStream, error)
	SetDelegate(StorageReceiver) error
	StopHandlingRequests() error
	ID() peer.ID
	AddAddrs(peer.ID, []ma.Multiaddr)

	PeerTagger
}

StorageMarketNetwork is a network abstraction for the storage market

func NewFromLibp2pHost

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

NewFromLibp2pHost builds a storage market network on top of libp2p

type StorageReceiver

type StorageReceiver interface {
	HandleAskStream(StorageAskStream)
	HandleDealStream(StorageDealStream)
	HandleDealStatusStream(DealStatusStream)
}

StorageReceiver implements functions for receiving incoming data on storage protocols

Jump to

Keyboard shortcuts

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