#[repr(C)]pub enum BidState {
EnglishAuction {
bids: Vec<Bid>,
max: usize,
},
OpenEdition {
bids: Vec<Bid>,
max: usize,
},
}Expand description
BidState tracks the running state of an auction, each variant represents a different kind of auction being run.
Variants§
Implementations§
Source§impl BidState
Bidding Implementations.
impl BidState
Bidding Implementations.
English Auction: this stores only the current winning bids in the auction, pruning cancelled and lost bids over time.
Open Edition: All bids are accepted, cancellations return money to the bidder and always succeed.
pub fn new_english(n: usize) -> Self
pub fn new_open_edition() -> Self
pub fn max_array_size_for(n: usize) -> usize
Sourcepub fn place_bid(
&mut self,
bid: Bid,
tick_size: Option<u64>,
gap_tick_size_percentage: Option<u8>,
minimum: u64,
instant_sale_price: Option<u64>,
auction_state: &mut AuctionState,
) -> Result<(), ProgramError>
pub fn place_bid( &mut self, bid: Bid, tick_size: Option<u64>, gap_tick_size_percentage: Option<u8>, minimum: u64, instant_sale_price: Option<u64>, auction_state: &mut AuctionState, ) -> Result<(), ProgramError>
Push a new bid into the state, this succeeds only if the bid is larger than the current top winner stored. Crappy list information to start with.
Sourcepub fn cancel_bid(&mut self, key: Pubkey) -> Result<(), ProgramError>
pub fn cancel_bid(&mut self, key: Pubkey) -> Result<(), ProgramError>
Cancels a bid, if the bid was a winning bid it is removed, if the bid is invalid the function simple no-ops.
pub fn amount(&self, index: usize) -> u64
Sourcepub fn is_winner(&self, key: &Pubkey, min: u64) -> Option<usize>
pub fn is_winner(&self, key: &Pubkey, min: u64) -> Option<usize>
Check if a pubkey is currently a winner and return winner #1 as index 0 to outside world.
pub fn num_winners(&self) -> u64
pub fn num_possible_winners(&self) -> u64
Sourcepub fn winner_at(&self, index: usize) -> Option<Pubkey>
pub fn winner_at(&self, index: usize) -> Option<Pubkey>
Idea is to present #1 winner as index 0 to outside world with this method
pub fn lowest_winning_bid_is_instant_bid_price( &self, instant_sale_amount: u64, ) -> bool
Trait Implementations§
Source§impl BorshDeserialize for BidState
impl BorshDeserialize for BidState
Source§impl BorshSerialize for BidState
impl BorshSerialize for BidState
impl StructuralPartialEq for BidState
Auto Trait Implementations§
impl Freeze for BidState
impl RefUnwindSafe for BidState
impl Send for BidState
impl Sync for BidState
impl Unpin for BidState
impl UnwindSafe for BidState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more