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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when the storage request doesn't exist.
	ErrNotFound = errors.New("storage request not found")
	// ErrInvalidCid is returned when the Cid is undefined.
	ErrInvalidCid = errors.New("the cid can't be undefined")
	// ErrEmptyGroup is returned when an empty batch group
	// is received.
	ErrEmptyGroup = errors.New("the batch group is empty")
	// ErrOperationIDExists indicates that the opeation already exists,
	// which basically means the function being called with the same data again.
	ErrOperationIDExists = errors.New("operation-id already exists")
)

Functions

This section is empty.

Types

type Broker

type Broker struct {
	// contains filtered or unexported fields
}

Broker creates and tracks request to store Cids in the Filecoin network.

func New

func New(
	postgresURI string,
	ipfsClient *httpapi.HttpApi,
	mb msgbroker.MsgBroker,
	opts ...Option,
) (*Broker, error)

New creates a new Broker.

func (*Broker) BatchAuctioned

func (b *Broker) BatchAuctioned(ctx context.Context, opID msgbroker.OperationID, au broker.ClosedAuction) (err error)

BatchAuctioned is called by the Auctioneer with the result of the Batch auction.

func (*Broker) BatchFinalizedDeal

func (b *Broker) BatchFinalizedDeal(ctx context.Context,
	opID msgbroker.OperationID,
	fad broker.FinalizedDeal) (err error)

BatchFinalizedDeal report a deal that reached final status in the Filecoin network.

func (*Broker) Close

func (b *Broker) Close() error

Close closes the broker.

func (*Broker) Create

func (b *Broker) Create(ctx context.Context, dataCid cid.Cid, origin string) (broker.StorageRequest, error)

Create creates a new StorageRequest with the provided Cid and Metadata configuration.

func (*Broker) CreateNewBatch

func (b *Broker) CreateNewBatch(
	ctx context.Context,
	batchID broker.BatchID,
	batchCid cid.Cid,
	batchSize int64,
	brIDs []broker.StorageRequestID,
	origin string,
	manifest []byte,
	carURL *url.URL) (broker.BatchID, error)

CreateNewBatch creates a Batch that contains multiple StorageRequest.

func (*Broker) CreatePrepared

func (b *Broker) CreatePrepared(
	ctx context.Context,
	payloadCid cid.Cid,
	pc broker.PreparedCAR,
	meta broker.BatchMetadata,
	rw *broker.RemoteWallet) (sr broker.StorageRequest, err error)

CreatePrepared creates a storage request for prepared data.

func (*Broker) GetBatch

func (b *Broker) GetBatch(ctx context.Context, id broker.BatchID) (broker.Batch, error)

GetBatch gets an existing batch. If the batch doesn't exists, it returns ErrNotFound.

func (*Broker) GetStorageRequestInfo

func (b *Broker) GetStorageRequestInfo(
	ctx context.Context,
	srID broker.StorageRequestID) (broker.StorageRequestInfo, error)

GetStorageRequestInfo gets a StorageRequest by id. If doesn't exist, it returns ErrNotFound.

func (*Broker) NewBatchPrepared

func (b *Broker) NewBatchPrepared(
	ctx context.Context,
	batchID broker.BatchID,
	dpr broker.DataPreparationResult,
) (err error)

NewBatchPrepared contains information of a prepared batch.

type Option

type Option func(*config) error

Option provides configuration for Broker.

func WithAuctionMaxRetries

func WithAuctionMaxRetries(max int) Option

WithAuctionMaxRetries indicates the maximum number of auctions that can be created for a batch.

func WithDealDuration

func WithDealDuration(duration uint64) Option

WithDealDuration configures the default deal duration of new auctions.

func WithDealReplication

func WithDealReplication(repFactor uint32) Option

WithDealReplication configures the default replication factor of new auctions.

func WithDefaultBatchDeadline

func WithDefaultBatchDeadline(duration time.Duration) Option

WithDefaultBatchDeadline indicates the default duration a direct auction batch can be re-auctioned before erroring.

func WithDefaultWalletAddress

func WithDefaultWalletAddress(walletAddress address.Address) Option

WithDefaultWalletAddress configures the default wallet address of new auctions.

func WithExportPinCountFrequency

func WithExportPinCountFrequency(freq time.Duration) Option

WithExportPinCountFrequency configures the frequency of exporting the pin count metric.

func WithProposalStartOffset

func WithProposalStartOffset(duration time.Duration) Option

WithProposalStartOffset indicates the default duration for DealStartEpoch from the current epoch if isn't provided by the client in the request.

func WithUnpinnerFrequency

func WithUnpinnerFrequency(freq time.Duration) Option

WithUnpinnerFrequency configures the frequency of the GC daemon.

func WithUnpinnerRetryDelay

func WithUnpinnerRetryDelay(delay time.Duration) Option

WithUnpinnerRetryDelay configures the default delay for failed unpin jobs to be retried.

func WithVerifiedDeals

func WithVerifiedDeals(verifiedDeals bool) Option

WithVerifiedDeals configures the default deal type in of new auctions.

Jump to

Keyboard shortcuts

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