broker

package
v0.0.0-...-269d6e4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CodecFilCommitmentUnsealed is the IPLD codec for PieceCid cids.
	CodecFilCommitmentUnsealed = 0xf101
	// MaxPieceSize is the maximum piece size accepted for prepared data.
	MaxPieceSize = 32 << 30
	// MinDealReplication is the minimum allowed deal replication requested of storage-providers.
	MinDealReplication = 1
	// MaxDealReplication is the maximum allowed deal replication requested of storage-providers.
	MaxDealReplication = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuctionStatus

type AuctionStatus string

AuctionStatus is the status of an auction.

const (
	// AuctionStatusUnspecified indicates the initial or invalid status of an auction.
	AuctionStatusUnspecified AuctionStatus = ""
	// AuctionStatusQueued indicates the auction is currently queued.
	AuctionStatusQueued AuctionStatus = "queued"
	// AuctionStatusStarted indicates the auction has started.
	AuctionStatusStarted AuctionStatus = "started"
	// AuctionStatusFinalized indicates the auction has reached a final state.
	// If ErrorCause is empty, the auction has received a sufficient number of bids.
	// If ErrorCause is not empty, a fatal error has occurred and the auction should be considered abandoned.
	AuctionStatusFinalized AuctionStatus = "finalized"
)

type Batch

type Batch struct {
	ID                  BatchID
	Status              BatchStatus
	RepFactor           int
	DealDuration        int
	Sources             auction.Sources
	DisallowRebatching  bool
	FilEpochDeadline    uint64
	ProposalStartOffset time.Duration
	Error               string
	Origin              string
	Tags                map[string]string
	Providers           []address.Address

	// Packer calculates this field after batching storage requests.
	PayloadCid  cid.Cid
	PayloadSize *int64

	// Piecer calculates these fields after preparing the batched DAG.
	PieceCid  cid.Cid
	PieceSize uint64
	CreatedAt time.Time
	UpdatedAt time.Time
}

Batch is the underlying entity that gets into bidding and store data in the Filecoin network. It groups one or multiple StorageRequests.

type BatchID

type BatchID string

BatchID is the type of a batch identifier.

type BatchMetadata

type BatchMetadata struct {
	Origin    string
	Tags      map[string]string
	Providers []address.Address
}

BatchMetadata is metadata about a batch.

type BatchStatus

type BatchStatus string

BatchStatus is the type of a broker status.

const (
	// BatchStatusUnkown is an invalid status value. Defined for safety.
	BatchStatusUnkown BatchStatus = "unknown"
	// BatchStatusPreparing indicates that the storage deal is being prepared.
	BatchStatusPreparing BatchStatus = "preparing"
	// BatchStatusAuctioning indicates that the storage deal is being auctioned.
	BatchStatusAuctioning BatchStatus = "auctioning"
	// BatchStatusDealMaking indicates that the storage deal deals are being executed.
	BatchStatusDealMaking BatchStatus = "deal_making"
	// BatchStatusSuccess indicates that the storage deal was successfully stored in Filecoin.
	BatchStatusSuccess BatchStatus = "success"
	// BatchStatusError indicates that the storage deal has errored.
	BatchStatusError BatchStatus = "error"
)

type Broker

type Broker interface {
	// Create creates a new StorageRequest for a cid.
	Create(ctx context.Context, dataCid cid.Cid, origin string) (StorageRequest, error)

	// CreatePrepared creates a new StorageRequest for prepared data.
	CreatePrepared(
		ctx context.Context,
		payloadCid cid.Cid,
		pc PreparedCAR,
		m BatchMetadata,
		rw *RemoteWallet) (StorageRequest, error)

	// GetStorageRequestInfo returns a storage request information by id.
	GetStorageRequestInfo(ctx context.Context, ID StorageRequestID) (StorageRequestInfo, error)
}

Broker provides full set of functionalities for Filecoin brokering.

type ClosedAuction

type ClosedAuction struct {
	ID              auction.ID
	BatchID         BatchID
	DealDuration    uint64
	DealReplication uint32
	DealVerified    bool
	Status          AuctionStatus
	WinningBids     map[auction.BidID]WinningBid
	ErrorCause      string
}

ClosedAuction contains closed auction details auctioneer reports back to the broker.

type DataPreparationResult

type DataPreparationResult struct {
	PieceSize uint64
	PieceCid  cid.Cid
}

DataPreparationResult is the result of preparing a batch.

func (DataPreparationResult) Validate

func (dpr DataPreparationResult) Validate() error

Validate returns an error if the struct contain invalid fields.

type FinalizedDeal

type FinalizedDeal struct {
	BatchID           BatchID
	StorageProviderID string
	DealID            int64
	DealExpiration    uint64
	ErrorCause        string
	AuctionID         auction.ID
	BidID             auction.BidID
}

FinalizedDeal contains information about a finalized deal.

type PreparedCAR

type PreparedCAR struct {
	PieceCid            cid.Cid
	PieceSize           uint64
	RepFactor           int
	Deadline            time.Time
	ProposalStartOffset time.Duration
	Sources             auction.Sources
}

PreparedCAR contains information about prepared data.

type RemoteWallet

type RemoteWallet struct {
	PeerID     peer.ID
	WalletAddr address.Address
	AuthToken  string
	Multiaddrs []multiaddr.Multiaddr
}

RemoteWallet contains configuration of a remote wallet.

type StorageRequest

type StorageRequest struct {
	ID        StorageRequestID
	DataCid   cid.Cid
	Status    StorageRequestStatus
	Origin    string
	BatchID   BatchID
	CreatedAt time.Time
	UpdatedAt time.Time
}

StorageRequest references a storage request for a Cid.

type StorageRequestDeal

type StorageRequestDeal struct {
	StorageProviderID string
	DealID            int64
	Expiration        uint64
}

StorageRequestDeal describes on-chain deals of a storage-request.

type StorageRequestID

type StorageRequestID string

StorageRequestID is the type used for storage request identity.

type StorageRequestInfo

type StorageRequestInfo struct {
	StorageRequest StorageRequest
	Deals          []StorageRequestDeal
}

StorageRequestInfo returns information about a storage request.

type StorageRequestStatus

type StorageRequestStatus string

StorageRequestStatus describe the current status of a StorageRequest.

const (
	// RequestUnknown is an invalid status value. Defined for safety.
	RequestUnknown StorageRequestStatus = "unknown"
	// RequestBatching indicates that a storage request is being batched.
	RequestBatching StorageRequestStatus = "batching"
	// RequestPreparing indicates that a storage request is being prepared.
	RequestPreparing StorageRequestStatus = "preparing"
	// RequestAuctioning indicates that a storage request is in bidding stage.
	RequestAuctioning StorageRequestStatus = "auctioning"
	// RequestDealMaking indicates that the storage request deals are being executed.
	RequestDealMaking StorageRequestStatus = "deal_making"
	// RequestSuccess indicates that the storage request was successfully stored in Filecoin.
	RequestSuccess StorageRequestStatus = "success"
	// RequestError indicates that the storage request storage errored.
	RequestError StorageRequestStatus = "error"
)

func (StorageRequestStatus) String

func (brs StorageRequestStatus) String() string

String returns a string-encoded status.

type WinningBid

type WinningBid struct {
	StorageProviderID string
	Price             int64
	StartEpoch        uint64
	FastRetrieval     bool
}

WinningBid contains details about a winning bid in a closed auction.

Jump to

Keyboard shortcuts

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