store

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 27 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
	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
	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 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,
	host host.Host,
	nodeGetter format.NodeGetter,
	lc lotusclient.LotusClient,
	dealDataDirectory string,
	dealDataFetchAttempts uint32,
	dealDataFetchTimeout time.Duration,
	discardOrphanDealsAfter time.Duration,
	bytesLimiter limiter.Limiter,
	concurrentImports int,
) (*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(discardOrphanDealsAfter time.Duration) (bidsRemoved, filesRemoved 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(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(bid Bid) error

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

func (*Store) SetAwaitingProposalCid

func (s *Store) SetAwaitingProposalCid(id auction.BidID) error

SetAwaitingProposalCid updates bid status to BidStatusAwaitingProposal. If a bid is not found for id, ErrBidNotFound is returned.

func (*Store) SetProposalCid

func (s *Store) SetProposalCid(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