Documentation ¶
Index ¶
- Constants
- Variables
- type AuctionConfig
- type Auctioneer
- func (a *Auctioneer) Close() error
- func (a *Auctioneer) CreateAuction(ctx context.Context, auction auctioneer.Auction) error
- func (a *Auctioneer) DeliverBoostProposal(ctx context.Context, auctionID core.ID, bidID core.BidID, dealUID string) error
- func (a *Auctioneer) DeliverProposal(ctx context.Context, auctionID core.ID, bidID core.BidID, pcid cid.Cid) error
- func (a *Auctioneer) GetAuction(ctx context.Context, id core.ID) (*auctioneer.Auction, error)
- func (a *Auctioneer) MarkFinalizedDeal(ctx context.Context, fad broker.FinalizedDeal) error
- func (a *Auctioneer) PeerInfo() (*rpcpeer.Info, error)
- func (a *Auctioneer) Start(bootstrap bool) error
- type BidbotEventsHandler
- type BidsHandler
- type BidsIter
- type Cmp
- type CommChannel
- type Libp2pPubsub
- func (ps *Libp2pPubsub) Close() error
- func (ps *Libp2pPubsub) Info() (*rpcpeer.Info, error)
- func (ps *Libp2pPubsub) ListPeers() []peer.ID
- func (ps *Libp2pPubsub) PublishAuction(ctx context.Context, id auction.ID, auctionPb *pb.Auction, ...) error
- func (ps *Libp2pPubsub) PublishProposal(ctx context.Context, id core.ID, bid core.BidID, bidder peer.ID, ...) error
- func (ps *Libp2pPubsub) PublishWin(ctx context.Context, id core.ID, bid core.BidID, bidder peer.ID, ...) error
- func (ps *Libp2pPubsub) Start(bootstrap bool) error
- type Sorter
- type Weighed
Constants ¶
const ( // NotifyTimeout is the max duration the auctioneer will wait for a response from bidders. NotifyTimeout = time.Second * 30 )
Variables ¶
var ( // ErrAuctionNotFound indicates the requested auction was not found. ErrAuctionNotFound = errors.New("auction not found") // ErrInsufficientBids indicates the auction failed due to insufficient bids. ErrInsufficientBids = errors.New("insufficient bids") )
Functions ¶
This section is empty.
Types ¶
type AuctionConfig ¶
AuctionConfig defines auction params.
type Auctioneer ¶
type Auctioneer struct {
// contains filtered or unexported fields
}
Auctioneer handles deal auctions for a broker.
func New ¶
func New( conf rpcpeer.Config, postgresURI string, mb mbroker.MsgBroker, fc filclient.FilClient, auctionConf AuctionConfig, recordBidbotEvents bool, ) (*Auctioneer, error)
New returns a new Auctioneer.
func (*Auctioneer) CreateAuction ¶
func (a *Auctioneer) CreateAuction(ctx context.Context, auction auctioneer.Auction) error
CreateAuction creates a new auction. New auctions are queued if the auctioneer is busy.
func (*Auctioneer) DeliverBoostProposal ¶
func (a *Auctioneer) DeliverBoostProposal( ctx context.Context, auctionID core.ID, bidID core.BidID, dealUID string) error
DeliverBoostProposal delivers the dealUID for an accepted deal to the winning bidder. This may be called multiple times by the broker in the event delivery fails.
func (*Auctioneer) DeliverProposal ¶
func (a *Auctioneer) DeliverProposal(ctx context.Context, auctionID core.ID, bidID core.BidID, pcid cid.Cid) error
DeliverProposal delivers the proposal Cid for an accepted deal to the winning bidder. This may be called multiple times by the broker in the event delivery fails.
func (*Auctioneer) GetAuction ¶
func (a *Auctioneer) GetAuction(ctx context.Context, id core.ID) (*auctioneer.Auction, error)
GetAuction returns an auction by id. If an auction is not found for id, ErrAuctionNotFound is returned.
func (*Auctioneer) MarkFinalizedDeal ¶
func (a *Auctioneer) MarkFinalizedDeal(ctx context.Context, fad broker.FinalizedDeal) error
MarkFinalizedDeal marks the deal as confirmed if it has no error.
func (*Auctioneer) PeerInfo ¶
func (a *Auctioneer) PeerInfo() (*rpcpeer.Info, error)
PeerInfo returns the peer info of the auctioneer.
func (*Auctioneer) Start ¶
func (a *Auctioneer) Start(bootstrap bool) error
Start the deal auction feed. If bootstrap is true, the peer will dial the configured bootstrap addresses before creating the deal auction feed.
type BidbotEventsHandler ¶
type BidbotEventsHandler func(peer.ID, *pb.BidbotEvent)
BidbotEventsHandler handles bidbot events.
type BidsHandler ¶
BidsHandler handles bids from bidbots.
type BidsIter ¶
type BidsIter func() (auctioneer.Bid, bool)
BidsIter provides a general way to iterate bids sorted by sorter.
func (BidsIter) MustNext ¶
func (i BidsIter) MustNext() auctioneer.Bid
MustNext is similar to Next, but panics when the next bid doesn't exist.
type Cmp ¶
type Cmp interface { // Cmp returns arbitrary number with the following semantics: // negative: i is considered to be less than j // zero: i is considered to be equal to j // positive: i is considered to be greater than j Cmp(a *auctioneer.Auction, i auctioneer.Bid, j auctioneer.Bid) int }
Cmp is the interface for a comparator.
func CmpFn ¶
func CmpFn(f func(a *auctioneer.Auction, i auctioneer.Bid, j auctioneer.Bid) int) Cmp
CmpFn is a helper which turns a function to a Cmp interface.
func EarlierStartEpoch ¶
EarlierStartEpoch returns a comparator which prefers bid with earlier start epoch. The difference between the start epochs in the scale of the resolution is returned.
func LowerPrice ¶
func LowerPrice() Cmp
LowerPrice returns a comparator which prefers lower ask price or verified ask price depending on if the auction is verified. The price difference is returned.
func LowerProviderRate ¶
LowerProviderRate returns a comparator which considers some rate of the storage provider. Provider with lower rate gets a higher chance to win. Provider not in the provided rates table are considered to have zero rate.
type CommChannel ¶
type CommChannel interface { PublishAuction(ctx context.Context, id auction.ID, auctionPb *pb.Auction, bidsHandler BidsHandler) error PublishWin(ctx context.Context, id auction.ID, bid auction.BidID, bidder peer.ID, sources auction.Sources) error PublishProposal(ctx context.Context, id auction.ID, bid auction.BidID, bidder peer.ID, identifier string) error Start(bootstrap bool) error Info() (*rpcpeer.Info, error) ListPeers() []peer.ID Close() error }
CommChannel represents the communication channel with bidbots.
type Libp2pPubsub ¶
type Libp2pPubsub struct {
// contains filtered or unexported fields
}
Libp2pPubsub communicates with bidbots via libp2p pubsub.
func NewLibp2pPubsub ¶
func NewLibp2pPubsub(ctx context.Context, conf rpcpeer.Config, eventsHandler BidbotEventsHandler) (*Libp2pPubsub, error)
NewLibp2pPubsub creates a communication channel backed by libp2p pubsub.
func (*Libp2pPubsub) Close ¶
func (ps *Libp2pPubsub) Close() error
Close closes the communication channel.
func (*Libp2pPubsub) Info ¶
func (ps *Libp2pPubsub) Info() (*rpcpeer.Info, error)
Info returns the peer info of the channel.
func (*Libp2pPubsub) ListPeers ¶
func (ps *Libp2pPubsub) ListPeers() []peer.ID
ListPeers returns the list of connected peers.
func (*Libp2pPubsub) PublishAuction ¶
func (ps *Libp2pPubsub) PublishAuction(ctx context.Context, id auction.ID, auctionPb *pb.Auction, bidsHandler BidsHandler) error
PublishAuction publishs the auction to the deal auction feed until the context expires, and calls the bid handler for each bid for the auction.
func (*Libp2pPubsub) PublishProposal ¶
func (ps *Libp2pPubsub) PublishProposal(ctx context.Context, id core.ID, bid core.BidID, bidder peer.ID, identifier string) error
PublishProposal publishs the proposal to the specific bidder.
func (*Libp2pPubsub) PublishWin ¶
func (ps *Libp2pPubsub) PublishWin(ctx context.Context, id core.ID, bid core.BidID, bidder peer.ID, sources core.Sources) error
PublishWin publishs the winning bid message to the specific bidder.
func (*Libp2pPubsub) Start ¶
func (ps *Libp2pPubsub) Start(bootstrap bool) error
Start creates the deal auction feed.
type Sorter ¶
type Sorter struct {
// contains filtered or unexported fields
}
Sorter has a single sort method which takes an aunction and some bids, then sort the bids based on the comparator given.
func BidsSorter ¶
func BidsSorter(auction *auctioneer.Auction, bids []auctioneer.Bid) *Sorter
BidsSorter constructs a sorter from the given comparator and bids.
func (*Sorter) RandomTopN ¶
RandomTopN returns an iterator which randomly choose one of the top N from the sorted list to return.
type Weighed ¶
type Weighed struct {
// contains filtered or unexported fields
}
Weighed combines comparators togethers with different weights. The result depends on both the weights given to each comparator and the scale of the comparison result of each comparator. Be aware to not cause integer overflow.
func (Weighed) Add ¶
Add returns a new weighed comparator with the comparator being added with the given weight.
func (Weighed) Cmp ¶
func (wc Weighed) Cmp(a *auctioneer.Auction, i auctioneer.Bid, j auctioneer.Bid) int
Cmp adds up the result of calling Cmp of each comparators with their respective weights.
Directories ¶
Path | Synopsis |
---|---|
migrations
Package migrations generated by go-bindata.// sources: migrations/001_init.down.sql migrations/001_init.up.sql migrations/002_bids_support_calculating_rates.down.sql migrations/002_bids_support_calculating_rates.up.sql migrations/003_auctions_add_client_address.down.sql migrations/003_auctions_add_client_address.up.sql migrations/004_bids_add_won_reason.down.sql migrations/004_bids_add_won_reason.up.sql migrations/005_auctions_add_providers.down.sql migrations/005_auctions_add_providers.up.sql migrations/006_consume_bidbot_events.down.sql migrations/006_consume_bidbot_events.up.sql migrations/007_bids_add_deal_failed_at.down.sql migrations/007_bids_add_deal_failed_at.up.sql migrations/008_leader_board.down.sql migrations/008_leader_board.up.sql migrations/009_leader_board_update.down.sql migrations/009_leader_board_update.up.sql migrations/010_leader_board_update2.down.sql migrations/010_leader_board_update2.up.sql migrations/011_leader_board_update3.down.sql migrations/011_leader_board_update3.up.sql migrations/012_leader_board_update4.down.sql migrations/012_leader_board_update4.up.sql migrations/013_leader_board_update5.down.sql migrations/013_leader_board_update5.up.sql migrations/014_leader_board_update6.down.sql migrations/014_leader_board_update6.up.sql
|
Package migrations generated by go-bindata.// sources: migrations/001_init.down.sql migrations/001_init.up.sql migrations/002_bids_support_calculating_rates.down.sql migrations/002_bids_support_calculating_rates.up.sql migrations/003_auctions_add_client_address.down.sql migrations/003_auctions_add_client_address.up.sql migrations/004_bids_add_won_reason.down.sql migrations/004_bids_add_won_reason.up.sql migrations/005_auctions_add_providers.down.sql migrations/005_auctions_add_providers.up.sql migrations/006_consume_bidbot_events.down.sql migrations/006_consume_bidbot_events.up.sql migrations/007_bids_add_deal_failed_at.down.sql migrations/007_bids_add_deal_failed_at.up.sql migrations/008_leader_board.down.sql migrations/008_leader_board.up.sql migrations/009_leader_board_update.down.sql migrations/009_leader_board_update.up.sql migrations/010_leader_board_update2.down.sql migrations/010_leader_board_update2.up.sql migrations/011_leader_board_update3.down.sql migrations/011_leader_board_update3.up.sql migrations/012_leader_board_update4.down.sql migrations/012_leader_board_update4.up.sql migrations/013_leader_board_update5.down.sql migrations/013_leader_board_update5.up.sql migrations/014_leader_board_update6.down.sql migrations/014_leader_board_update6.up.sql |