aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brandt.c17
-rw-r--r--brandt.h22
-rw-r--r--internals.h7
3 files changed, 39 insertions, 7 deletions
diff --git a/brandt.c b/brandt.c
index e90ec2f..edfca62 100644
--- a/brandt.c
+++ b/brandt.c
@@ -50,12 +50,25 @@ BRANDT_init (struct GNUNET_CRYPTO_EccDlogContext *dlogctx)
50} 50}
51 51
52 52
53BRANDT_start (struct BRANDT_Auction *auction,
54 uint16_t n){
55 GNUNET_assert (n > 0);
56 auction->n = n;
57 /** \todo: send first message */
58}
59
60
53static void 61static void
54start_auction (void *arg) 62start_auction (void *arg)
55{ 63{
56// struct BRANDT_Auction *ad = (struct BRANDT_Auction *)arg; 64 struct BRANDT_Auction *ad = (struct BRANDT_Auction *)arg;
57 65
58 /* \todo: broadcast start message to all participants */ 66 if (0 == (ad->n = ad->start (ad->closure)))
67 {
68 weprintf ("no bidders registered for auction");
69 ad->result (ad->closure, -1, result_no_bidders, 0);
70 return;
71 }
59} 72}
60 73
61 74
diff --git a/brandt.h b/brandt.h
index 1903301..385d67b 100644
--- a/brandt.h
+++ b/brandt.h
@@ -92,15 +92,16 @@ typedef int
92 * auction. This is the Pointer given to BRANDT_join() / BRANDT_new(). 92 * auction. This is the Pointer given to BRANDT_join() / BRANDT_new().
93 * @param[in] bidder_id The numeric Id of the bidder this report refers to. 93 * @param[in] bidder_id The numeric Id of the bidder this report refers to.
94 * @param[in] status 1 if the user @a bidder_id has won the auction, 0 if he has 94 * @param[in] status 1 if the user @a bidder_id has won the auction, 0 if he has
95 * lost, -1 if erroneous behaviour was detected. 95 * lost, negative if erroneous behaviour was detected. Check the result_code
96 * enum for more information.
96 * @param[in] price The price, the winner has to pay or 0 if the auction result 97 * @param[in] price The price, the winner has to pay or 0 if the auction result
97 * is private and the user did not win. 98 * is private and the user did not win.
98 */ 99 */
99typedef void 100typedef void
100(*BRANDT_CbResult)(void *auction_closure, 101(*BRANDT_CbResult)(void *auction_closure,
101 unsigned int bidder_id, 102 int32_t bidder_id,
102 int status, 103 int status,
103 uint16_t price); 104 uint16_t price);
104 105
105 106
106void 107void
@@ -214,6 +215,17 @@ BRANDT_new (BRANDT_CbResult result,
214 215
215 216
216/** 217/**
218 * This function must be called when bidding after receipt of the start
219 * notification.
220 *
221 * @param[in] auction The pointer returned by BRANDT_join().
222 * @param[in] n The amount of bidders (from the start announcement message).
223 void
224 BRANDT_start (struct BRANDT_Auction *auction,
225 uint16_t n);
226
227
228 /**
217 * Clean up this auction on shutdown. 229 * Clean up this auction on shutdown.
218 * 230 *
219 * @param[in] auction The pointer returned by BRANDT_join() or BRANDT_new(). 231 * @param[in] auction The pointer returned by BRANDT_join() or BRANDT_new().
diff --git a/internals.h b/internals.h
index a1c939a..c478f4f 100644
--- a/internals.h
+++ b/internals.h
@@ -51,6 +51,13 @@ enum outcome_type {
51}; 51};
52 52
53 53
54enum result_code {
55 result_loser = 0,
56 result_winner = 1,
57 result_no_bidders = -2
58};
59
60
54GNUNET_NETWORK_STRUCT_BEGIN 61GNUNET_NETWORK_STRUCT_BEGIN
55 62
56struct msg_head { 63struct msg_head {