aboutsummaryrefslogtreecommitdiff
path: root/brandt.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-12-02 12:53:54 +0100
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-12-02 12:53:54 +0100
commite66cbbe44f3708e6d6a30b216035bcccfc8e7207 (patch)
tree5329f963c2eee3af18976862cdfdf9e344dfd109 /brandt.c
parent64689a9083fd11a1e482cc86c0417183cdc76ece (diff)
move ecdlogctx passing to _join()/_new() functions
Diffstat (limited to 'brandt.c')
-rw-r--r--brandt.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/brandt.c b/brandt.c
index f5bb4fa..bd6e01e 100644
--- a/brandt.c
+++ b/brandt.c
@@ -28,7 +28,7 @@
void
-BRANDT_init (struct GNUNET_CRYPTO_EccDlogContext *dlogctx)
+BRANDT_init ()
{
gcry_error_t err = 0;
@@ -56,7 +56,7 @@ BRANDT_init (struct GNUNET_CRYPTO_EccDlogContext *dlogctx)
gcry_strerror (err));
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
- brandt_crypto_init (dlogctx);
+ brandt_crypto_init ();
}
@@ -184,17 +184,18 @@ seller_start (void *arg)
struct BRANDT_Auction *
-BRANDT_new (BRANDT_CbResult result,
- BRANDT_CbDeliver broadcast,
- BRANDT_CbStart start,
- void *auction_closure,
- void **auction_desc,
- size_t *auction_desc_len,
- struct GNUNET_TIME_Absolute time_start,
- struct GNUNET_TIME_Relative time_round,
- uint16_t num_prices,
- uint16_t m,
- int outcome_public)
+BRANDT_new (BRANDT_CbResult result,
+ BRANDT_CbDeliver broadcast,
+ BRANDT_CbStart start,
+ void *auction_closure,
+ void **auction_desc,
+ size_t *auction_desc_len,
+ struct GNUNET_TIME_Absolute time_start,
+ struct GNUNET_TIME_Relative time_round,
+ uint16_t num_prices,
+ uint16_t m,
+ int outcome_public,
+ struct GNUNET_CRYPTO_EccDlogContext *dlogctx)
{
struct BRANDT_Auction *ret;
struct BRANDT_DescrP *desc;
@@ -208,6 +209,14 @@ BRANDT_new (BRANDT_CbResult result,
return NULL;
}
+ if (1 == outcome_public && NULL == dlogctx)
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ "libbrandt",
+ "need dlogctx for public outcome auctions\n");
+ return NULL;
+ }
+
desc = GNUNET_new (struct BRANDT_DescrP);
desc->time_start = GNUNET_TIME_absolute_hton (time_start);
desc->time_round = GNUNET_TIME_relative_hton (time_round);
@@ -223,6 +232,7 @@ BRANDT_new (BRANDT_CbResult result,
ret->outcome_public = outcome_public;
ret->cur_round = msg_init;
ret->round_progress = gcry_mpi_new (256);
+ ret->dlogctx = dlogctx;
/* we are the seller */
ret->seller_mode = 1;
@@ -288,13 +298,14 @@ BRANDT_parse_desc (const void *auction_desc,
struct BRANDT_Auction *
-BRANDT_join (BRANDT_CbResult result,
- BRANDT_CbDeliver broadcast,
- BRANDT_CbDeliver unicast,
- void *auction_closure,
- const void *auction_desc,
- size_t auction_desc_len,
- uint16_t bid)
+BRANDT_join (BRANDT_CbResult result,
+ BRANDT_CbDeliver broadcast,
+ BRANDT_CbDeliver unicast,
+ void *auction_closure,
+ const void *auction_desc,
+ size_t auction_desc_len,
+ uint16_t bid,
+ struct GNUNET_CRYPTO_EccDlogContext *dlogctx)
{
struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction);
@@ -312,9 +323,20 @@ BRANDT_join (BRANDT_CbResult result,
"failed to parse auction description blob\n");
return NULL;
}
+
+ if (1 == ret->outcome_public && NULL == dlogctx)
+ {
+ GNUNET_free (ret);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ "libbrandt",
+ "need dlogctx for public outcome auctions\n");
+ return NULL;
+ }
+
ret->cur_round = msg_init;
ret->round_progress = gcry_mpi_new (256);
ret->b = bid;
+ ret->dlogctx = dlogctx;
/* we are the seller */
ret->seller_mode = 0;