store

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned if the storage request doesn't exist.
	ErrNotFound = fmt.Errorf("not found")

	// ErrBatchExists if the provided batch id already exists.
	ErrBatchExists = errors.New("batch-id already exists")

	// ErrBatchInAuction if the provided batch id is already in auction status.
	ErrBatchInAuction = errors.New("batch-id already in auction")

	// ErrBatchContainsUnknownStorageRequest is returned if a batch contains an
	// unknown storage request.
	ErrBatchContainsUnknownStorageRequest = fmt.Errorf("batch contains an unknown storage request")
)

Functions

This section is empty.

Types

type Store

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

Store provides a persistent layer for storage requests.

func New

func New(postgresURI string) (*Store, error)

New returns a new Store backed by `postgresURI`.

func (*Store) AddDeals

func (s *Store) AddDeals(ctx context.Context, auction broker.ClosedAuction) (acceptedWinners []string, err error)

AddDeals includes new deals from a finalized auction. Confirming the winners in the database can discover the fact that a concurrent auction already made some of them winners. The fully confirmed accepted winners are returned in the acceptedWinners return parameter.

func (*Store) BatchError

func (s *Store) BatchError(
	ctx context.Context,
	id broker.BatchID,
	errorCause string,
	rebatch bool) (brIDs []broker.StorageRequestID, err error)

BatchError moves a batch to an error status with a specified error cause.

func (*Store) BatchSuccess

func (s *Store) BatchSuccess(ctx context.Context, id broker.BatchID) error

BatchSuccess moves a batch and the underlying storage requests to Success status.

func (*Store) BatchToAuctioning

func (s *Store) BatchToAuctioning(
	ctx context.Context,
	id broker.BatchID,
	pieceCid cid.Cid,
	pieceSize uint64) error

BatchToAuctioning moves a batch and the underlying storage requests to Auctioning status.

func (*Store) CreateBatch

func (s *Store) CreateBatch(
	ctx context.Context,
	ba *broker.Batch,
	brIDs []broker.StorageRequestID,
	manifest []byte,
	rw *broker.RemoteWallet) error

CreateBatch persists a batch.

func (*Store) CreateStorageRequest

func (s *Store) CreateStorageRequest(ctx context.Context, br broker.StorageRequest) error

CreateStorageRequest creates the provided StorageRequest in store.

func (*Store) CtxWithTx

func (s *Store) CtxWithTx(ctx context.Context, opts ...storeutil.TxOptions) (context.Context, error)

CtxWithTx attach a database transaction to the context. It returns the context unchanged if there's error starting the transaction.

func (*Store) DeleteExecuting

func (s *Store) DeleteExecuting(ctx context.Context, id string) error

DeleteExecuting removes an executing unpin job.

func (*Store) GetBatch

func (s *Store) GetBatch(ctx context.Context, id broker.BatchID) (ba *broker.Batch, err error)

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

func (*Store) GetBatchManifest

func (s *Store) GetBatchManifest(ctx context.Context, id broker.BatchID) ([]byte, error)

GetBatchManifest gets the stored manifest of a batch. If none is found it returns ErrNotFound.

func (*Store) GetDeals

func (s *Store) GetDeals(ctx context.Context, id broker.BatchID) (deals []db.Deal, err error)

GetDeals gets storage-provider deals for a batch.

func (*Store) GetExcludedStorageProviders

func (s *Store) GetExcludedStorageProviders(
	ctx context.Context,
	pieceCid cid.Cid,
	origin string) (sps []string, err error)

GetExcludedStorageProviders returns a list of all storage providers that have won auctions fired by the origin for the provided PieceCid. Note that this considers all auctions history for the PieceCid and the origin.

func (*Store) GetRemoteWalletConfig

func (s *Store) GetRemoteWalletConfig(ctx context.Context, id broker.BatchID) (rw *broker.RemoteWallet, err error)

GetRemoteWalletConfig gets the remote wallet configured to sign deals from a batch. If none was configured, it *does not return an error but a nil result*.

func (*Store) GetStorageRequest

func (s *Store) GetStorageRequest(
	ctx context.Context,
	id broker.StorageRequestID) (br broker.StorageRequest, err error)

GetStorageRequest gets a StorageRequest with the specified `id`. If not found returns ErrNotFound.

func (*Store) GetStorageRequestIDs

func (s *Store) GetStorageRequestIDs(ctx context.Context, id broker.BatchID) (
	brIDs []broker.StorageRequestID, err error)

GetStorageRequestIDs gets the ids of the storage requests for a batch.

func (*Store) OperationExists

func (s *Store) OperationExists(ctx context.Context, opID string) (exists bool, err error)

OperationExists checks if the operation ID already exists in db.

func (*Store) SaveDeals

func (s *Store) SaveDeals(ctx context.Context, fad broker.FinalizedDeal) error

SaveDeals saves a new finalized (succeeded or errored) auction deal into the batch.

func (*Store) UnpinJobGetNext

func (s *Store) UnpinJobGetNext(ctx context.Context) (UnpinJob, bool, error)

UnpinJobGetNext returns the next pending unpin job to execute.

func (*Store) UnpinJobMoveToPending

func (s *Store) UnpinJobMoveToPending(ctx context.Context, id string, delay time.Duration) error

UnpinJobMoveToPending moves an unpin job to pending status.

type UnpinJob

type UnpinJob db.UnpinJob

UnpinJob describes a job to unpin a Cid.

type UnpinType

type UnpinType int

UnpinType is the type of an UnpinJob.

const (
	// UnpinTypeBatch is the type of batch unpins.
	UnpinTypeBatch UnpinType = iota
	// UnpinTypeData is the type of data unpins.
	UnpinTypeData
)

Directories

Path Synopsis
internal
db
Package migrations generated by go-bindata.// sources: migrations/001_init.down.sql migrations/001_init.up.sql migrations/002_rw.down.sql migrations/002_rw.up.sql migrations/003_providers.down.sql migrations/003_providers.up.sql migrations/004_status_enums.down.sql migrations/004_status_enums.up.sql migrations/005_payload_size.down.sql migrations/005_payload_size.up.sql migrations/006_add_dealstartoffset.down.sql migrations/006_add_dealstartoffset.up.sql migrations/007_piececididx.down.sql migrations/007_piececididx.up.sql
Package migrations generated by go-bindata.// sources: migrations/001_init.down.sql migrations/001_init.up.sql migrations/002_rw.down.sql migrations/002_rw.up.sql migrations/003_providers.down.sql migrations/003_providers.up.sql migrations/004_status_enums.down.sql migrations/004_status_enums.up.sql migrations/005_payload_size.down.sql migrations/005_payload_size.up.sql migrations/006_add_dealstartoffset.down.sql migrations/006_add_dealstartoffset.up.sql migrations/007_piececididx.down.sql migrations/007_piececididx.up.sql

Jump to

Keyboard shortcuts

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