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
- Variables
- type AskRequest
- type AskResponse
- type DealStatusRequest
- type DealStatusResponse
- type DealStatusStream
- type Option
- func RetryParameters(minDuration time.Duration, maxDuration time.Duration, attempts float64, ...) Option
- func SupportedAskProtocols(supportedProtocols []protocol.ID) Option
- func SupportedDealProtocols(supportedProtocols []protocol.ID) Option
- func SupportedDealStatusProtocols(supportedProtocols []protocol.ID) Option
- type PeerTagger
- type Proposal
- type ResigningFunc
- type Response
- type SignedResponse
- type StorageAskStream
- type StorageDealStream
- type StorageMarketNetwork
- type StorageReceiver
Constants ¶
const TagPriority = 100
TagPriority is the priority for deal streams -- they should generally be preserved above all else
Variables ¶
var AskRequestUndefined = AskRequest{}
AskRequestUndefined represents and empty AskRequest message
var AskResponseUndefined = AskResponse{}
AskResponseUndefined represents an empty AskResponse message
var DealStatusRequestUndefined = DealStatusRequest{}
DealStatusRequestUndefined represents an empty DealStatusRequest message
var DealStatusResponseUndefined = DealStatusResponse{}
DealStatusResponseUndefined represents an empty DealStatusResponse message
var ProposalUndefined = Proposal{}
ProposalUndefined is an empty Proposal message
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 ¶
DealStatusRequest sent by a client to query deal status
func (*DealStatusRequest) MarshalCBOR ¶
func (t *DealStatusRequest) MarshalCBOR(w io.Writer) error
func (*DealStatusRequest) UnmarshalCBOR ¶
func (t *DealStatusRequest) UnmarshalCBOR(r io.Reader) (err error)
type DealStatusResponse ¶
type DealStatusResponse struct { DealState storagemarket.ProviderDealState Signature crypto.Signature }
DealStatusResponse is a provider's response to DealStatusRequest
func (*DealStatusResponse) MarshalCBOR ¶
func (t *DealStatusResponse) MarshalCBOR(w io.Writer) error
func (*DealStatusResponse) UnmarshalCBOR ¶
func (t *DealStatusResponse) UnmarshalCBOR(r io.Reader) (err error)
type DealStatusStream ¶
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 ¶
type Option func(*libp2pStorageMarketNetwork)
Option is an option for configuring the libp2p storage market network
func RetryParameters ¶
func RetryParameters(minDuration time.Duration, maxDuration time.Duration, attempts float64, backoffFactor float64) Option
RetryParameters changes the default parameters around connection reopening
func SupportedAskProtocols ¶
SupportedAskProtocols sets what ask protocols this network instances listens on
func SupportedDealProtocols ¶
SupportedDealProtocols sets what deal protocols this network instances listens on
func SupportedDealStatusProtocols ¶
SupportedDealStatusProtocols sets what deal status protocols this network instances listens on
type PeerTagger ¶
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
type ResigningFunc ¶
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
type SignedResponse ¶
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