get auctions rolling
This commit is contained in:
parent
8daaa565bd
commit
25321ed0f5
17
brandt.c
17
brandt.c
@ -50,12 +50,25 @@ BRANDT_init (struct GNUNET_CRYPTO_EccDlogContext *dlogctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRANDT_start (struct BRANDT_Auction *auction,
|
||||||
|
uint16_t n){
|
||||||
|
GNUNET_assert (n > 0);
|
||||||
|
auction->n = n;
|
||||||
|
/** \todo: send first message */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
start_auction (void *arg)
|
start_auction (void *arg)
|
||||||
{
|
{
|
||||||
// struct BRANDT_Auction *ad = (struct BRANDT_Auction *)arg;
|
struct BRANDT_Auction *ad = (struct BRANDT_Auction *)arg;
|
||||||
|
|
||||||
/* \todo: broadcast start message to all participants */
|
if (0 == (ad->n = ad->start (ad->closure)))
|
||||||
|
{
|
||||||
|
weprintf ("no bidders registered for auction");
|
||||||
|
ad->result (ad->closure, -1, result_no_bidders, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
22
brandt.h
22
brandt.h
@ -92,15 +92,16 @@ typedef int
|
|||||||
* auction. This is the Pointer given to BRANDT_join() / BRANDT_new().
|
* auction. This is the Pointer given to BRANDT_join() / BRANDT_new().
|
||||||
* @param[in] bidder_id The numeric Id of the bidder this report refers to.
|
* @param[in] bidder_id The numeric Id of the bidder this report refers to.
|
||||||
* @param[in] status 1 if the user @a bidder_id has won the auction, 0 if he has
|
* @param[in] status 1 if the user @a bidder_id has won the auction, 0 if he has
|
||||||
* lost, -1 if erroneous behaviour was detected.
|
* lost, negative if erroneous behaviour was detected. Check the result_code
|
||||||
|
* enum for more information.
|
||||||
* @param[in] price The price, the winner has to pay or 0 if the auction result
|
* @param[in] price The price, the winner has to pay or 0 if the auction result
|
||||||
* is private and the user did not win.
|
* is private and the user did not win.
|
||||||
*/
|
*/
|
||||||
typedef void
|
typedef void
|
||||||
(*BRANDT_CbResult)(void *auction_closure,
|
(*BRANDT_CbResult)(void *auction_closure,
|
||||||
unsigned int bidder_id,
|
int32_t bidder_id,
|
||||||
int status,
|
int status,
|
||||||
uint16_t price);
|
uint16_t price);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -214,6 +215,17 @@ BRANDT_new (BRANDT_CbResult result,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This function must be called when bidding after receipt of the start
|
||||||
|
* notification.
|
||||||
|
*
|
||||||
|
* @param[in] auction The pointer returned by BRANDT_join().
|
||||||
|
* @param[in] n The amount of bidders (from the start announcement message).
|
||||||
|
void
|
||||||
|
BRANDT_start (struct BRANDT_Auction *auction,
|
||||||
|
uint16_t n);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
* Clean up this auction on shutdown.
|
* Clean up this auction on shutdown.
|
||||||
*
|
*
|
||||||
* @param[in] auction The pointer returned by BRANDT_join() or BRANDT_new().
|
* @param[in] auction The pointer returned by BRANDT_join() or BRANDT_new().
|
||||||
|
@ -51,6 +51,13 @@ enum outcome_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum result_code {
|
||||||
|
result_loser = 0,
|
||||||
|
result_winner = 1,
|
||||||
|
result_no_bidders = -2
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
GNUNET_NETWORK_STRUCT_BEGIN
|
GNUNET_NETWORK_STRUCT_BEGIN
|
||||||
|
|
||||||
struct msg_head {
|
struct msg_head {
|
||||||
|
Loading…
Reference in New Issue
Block a user