store

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DataURIFetchStartDelay is the time delay before the store will process queued data uri fetches on start.
	DataURIFetchStartDelay = time.Second * 10

	// MaxDataURIFetchConcurrency is the maximum number of data uri fetches that will be handled concurrently.
	MaxDataURIFetchConcurrency = 3

	// ErrBidNotFound indicates the requested bid was not found.
	ErrBidNotFound = errors.New("bid not found")
)

Functions

This section is empty.

Types

type Bid

type Bid struct {
	ID                   auction.BidID
	AuctionID            auction.ID
	AuctioneerID         peer.ID
	PayloadCid           cid.Cid
	DealSize             uint64
	DealDuration         uint64
	ClientAddress        string
	Sources              auction.Sources
	Status               BidStatus
	AskPrice             int64 // attoFIL per GiB per epoch
	VerifiedAskPrice     int64 // attoFIL per GiB per epoch
	StartEpoch           uint64
	FastRetrieval        bool
	ProposalCid          cid.Cid
	DealUID              string
	DataURIFetchAttempts uint32
	CreatedAt            time.Time
	UpdatedAt            time.Time
	ErrorCause           string
}

Bid defines the core bid model from a miner's perspective.

type BidStatus

type BidStatus int

BidStatus is the status of a Bid.

const (
	// BidStatusUnspecified indicates the initial or invalid status of a bid.
	BidStatusUnspecified BidStatus = iota
	// BidStatusSubmitted indicates the bid was successfully submitted to the auctioneer.
	BidStatusSubmitted
	// BidStatusAwaitingProposal indicates the bid was accepted and is awaiting proposal cid from auctioneer.
	BidStatusAwaitingProposal
	// BidStatusQueuedData indicates the bid proposal cid was received but data fetching is queued.
	BidStatusQueuedData
	// BidStatusFetchingData indicates the bid data uri is being fetched.
	BidStatusFetchingData
	// BidStatusFinalized indicates the bid has been accepted and the data has been imported to Lotus.
	BidStatusFinalized
	// BidStatusErrored indicates a fatal error has occurred and the bid should be considered abandoned.
	BidStatusErrored
)

func BidStatusByString

func BidStatusByString(s string) (BidStatus, error)

BidStatusByString finds a status by its string representation, or errors if the status does not exist.

func (BidStatus) String

func (as BidStatus) String() string

String returns a string-encoded status.

type Order

type Order int

Order specifies the order of list results. Default is decending by time created.

const (
	// OrderDescending orders results decending.
	OrderDescending Order = iota
	// OrderAscending orders results ascending.
	OrderAscending
)

type ProgressReporter added in v0.1.2

type ProgressReporter interface {
	StartFetching(bidID auction.BidID, attempts uint32)
	ErrorFetching(bidID auction.BidID, attempts uint32, err error)
	StartImporting(bidID auction.BidID, attempts uint32)
	EndImporting(bidID auction.BidID, attempts uint32, err error)
	Finalized(bidID auction.BidID)
	Errored(bidID auction.BidID, errrorCause string)
}

ProgressReporter reports the progress processing a deal.

type Query

type Query struct {
	Offset string
	Order  Order
	Limit  int
}

Query is used to query for bids.

type Store

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

Store stores miner auction deal bids.

func NewStore

func NewStore(
	store txndswrap.TxnDatastore,
	fc filclient.FilClient,
	lc lotusclient.LotusClient,
	dealDataDirectory string,
	dealDataFetchAttempts uint32,
	dealDataFetchTimeout time.Duration,
	dealProgressReporter ProgressReporter,
	discardOrphanDealsAfter time.Duration,
	bytesLimiter limiter.Limiter,
	concurrentImports int,
	chunkedDownload bool,
) (*Store, error)

NewStore returns a new Store.

func (*Store) Close

func (s *Store) Close() error

Close the store. This will wait for "fetching" data uri fetches.

func (*Store) GC

func (s *Store) GC(
	ctx context.Context,
	discardOrphanDealsAfter time.Duration) (bidsRemoved, filesRemoved, filesEvaluated int)

GC cleans up deal data files, if discardOrphanDealsAfter is not zero, it also removes bids staying at BidStatusAwaitingProposal for that longer.

func (*Store) GetBid

func (s *Store) GetBid(ctx context.Context, id auction.BidID) (*Bid, error)

GetBid returns a bid by id. If a bid is not found for id, ErrBidNotFound is returned.

func (*Store) HealthCheck

func (s *Store) HealthCheck() error

HealthCheck checks if the store is healthy enough to participate in bidding.

func (*Store) ListBids

func (s *Store) ListBids(query Query) ([]*Bid, error)

ListBids lists bids by applying a Query.

func (*Store) SaveBid

func (s *Store) SaveBid(ctx context.Context, bid Bid) error

SaveBid saves a bid that has been submitted to an auctioneer.

func (*Store) SetAwaitingProposalCid

func (s *Store) SetAwaitingProposalCid(ctx context.Context, id auction.BidID, sources auction.Sources) error

SetAwaitingProposalCid updates bid with the given sources and switch status to BidStatusAwaitingProposal. If a bid is not found for id, ErrBidNotFound is returned.

func (*Store) SetDealUID added in v0.1.14

func (s *Store) SetDealUID(ctx context.Context, id auction.BidID, dealUID string) error

SetDealUID sets the DealUID and updates status to BidStatusFinalized. If a bid is not found for id, ErrBidNotFound is returned.

func (*Store) SetProposalCid

func (s *Store) SetProposalCid(ctx context.Context, id auction.BidID, pcid cid.Cid) error

SetProposalCid sets the bid proposal cid and updates status to BidStatusQueuedData. If a bid is not found for id, ErrBidNotFound is returned.

func (*Store) WriteDataURI

func (s *Store) WriteDataURI(bidID auction.BidID, payloadCid, uri string, size uint64) (string, error)

WriteDataURI writes the uri resource to the configured deal data directory.

func (*Store) WriteDealData

func (s *Store) WriteDealData(b *Bid) (string, error)

WriteDealData writes the deal data to the configured deal data directory.

Jump to

Keyboard shortcuts

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