-commenting on code
This commit is contained in:
parent
d5f6b064f5
commit
4544a21cfb
@ -21,6 +21,14 @@
|
||||
#ifndef TALER_AMOUNT_LIB_H
|
||||
#define TALER_AMOUNT_LIB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#if 0 /* keep Emacsens' auto-indent happy */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Number of characters (plus 1 for 0-termination) we use to
|
||||
@ -249,5 +257,12 @@ TALER_amount_normalize (struct TALER_Amount *amount);
|
||||
char *
|
||||
TALER_amount_to_string (const struct TALER_Amount *amount);
|
||||
|
||||
#if 0 /* keep Emacsens' auto-indent happy */
|
||||
{
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -25,6 +25,14 @@
|
||||
#include "taler_crypto_lib.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#if 0 /* keep Emacsens' auto-indent happy */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Define logging functions */
|
||||
#define TALER_LOG_DEBUG(...) \
|
||||
@ -86,4 +94,12 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
struct TALER_Amount *denom);
|
||||
|
||||
|
||||
#if 0 /* keep Emacsens' auto-indent happy */
|
||||
{
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -10,28 +10,35 @@
|
||||
#define CURRENCY "EUR\0\0\0\0\0\0\0\0"
|
||||
|
||||
struct TALER_MINTDB_CollectableBlindcoin *
|
||||
init_CollectableBlindcoin(){
|
||||
struct TALER_MINTDB_CollectableBlindcoin *coin = GNUNET_malloc(sizeof(*coin));
|
||||
init_CollectableBlindcoin ()
|
||||
{
|
||||
// indent by 2 spaces
|
||||
struct TALER_MINTDB_CollectableBlindcoin *coin = GNUNET_new (*coin);
|
||||
|
||||
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create();
|
||||
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key = GNUNET_CRYPTO_rsa_private_key_create(512);
|
||||
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_sig_key = GNUNET_CRYPTO_eddsa_key_create ();
|
||||
struct GNUNET_CRYPTO_rsa_PrivateKey *denomination_key = GNUNET_CRYPTO_rsa_private_key_create (512);
|
||||
|
||||
|
||||
coin->denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public(denomination_key);
|
||||
GNUNET_CRYPTO_eddsa_key_get_public(reserve_sig_key, &(coin->reserve_pub.eddsa_pub));
|
||||
coin->denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (denomination_key);
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (reserve_sig_key,
|
||||
&coin->reserve_pub.eddsa_pub);
|
||||
|
||||
|
||||
//TODO Randomise the amount that is deposited and apply a fee subsequently
|
||||
|
||||
// GNUNET_assert (GNUNET_OK ==
|
||||
// TALER_string_to_amount (CURRENCY ":1.1",
|
||||
// &coin->amount_with_fee));
|
||||
|
||||
coin->amount_with_fee = (struct TALER_Amount) {1, 1, CURRENCY};
|
||||
coin->withdraw_fee = (struct TALER_Amount) {0, 1, CURRENCY};
|
||||
|
||||
|
||||
int random_int = rand();
|
||||
int random_int = rand(); // GNUNET_CRYPTO_random_u32
|
||||
coin->sig.rsa_signature = GNUNET_CRYPTO_rsa_sign(denomination_key, &random_int, sizeof(random_int));
|
||||
GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK , &(coin->h_coin_envelope));
|
||||
GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &coin->h_coin_envelope);
|
||||
|
||||
void *purpose = GNUNET_malloc(sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof(int));
|
||||
void *purpose = GNUNET_malloc (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof(int));
|
||||
((struct GNUNET_CRYPTO_EccSignaturePurpose *)purpose)->size = sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof(int);
|
||||
((struct GNUNET_CRYPTO_EccSignaturePurpose *)purpose)->purpose = GNUNET_SIGNATURE_PURPOSE_TEST;
|
||||
*((int *)(purpose + sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose))) = random_int;
|
||||
@ -252,7 +259,3 @@ free_denomination(struct TALER_MINTDB_DenominationKeyIssueInformation *dki){
|
||||
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -8,20 +8,20 @@
|
||||
#include <taler/taler_mintdb_plugin.h>
|
||||
|
||||
|
||||
#define CURRENCY "EUR\0\0\0\0\0\0\0\0"
|
||||
#define CURRENCY "EUR"
|
||||
|
||||
|
||||
struct TALER_MINTDB_CollectableBlindcoin *
|
||||
init_collectableBlindcoin();
|
||||
init_collectable_blindcoin(void);
|
||||
|
||||
struct TALER_MINTDB_RefreshSession *
|
||||
init_refresh_session();
|
||||
init_refresh_session(void);
|
||||
|
||||
struct TALER_MINTDB_Deposit *
|
||||
init_deposit(int transaction_id);
|
||||
|
||||
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
||||
init_denomination();
|
||||
init_denomination(void);
|
||||
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ int
|
||||
free_deposit(struct TALER_MINTDB_Deposit *deposit);
|
||||
|
||||
int
|
||||
free_collectableBlindcoin(struct TALER_MINTDB_CollectableBlindcoin);
|
||||
free_collectable_blindcoin(struct TALER_MINTDB_CollectableBlindcoin *NAME);
|
||||
|
||||
int
|
||||
free_denomination(struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
|
||||
|
@ -14,20 +14,12 @@
|
||||
static int
|
||||
cmd_find(const struct PERF_TALER_MINTDB_CMD *cmd, const char *search)
|
||||
{
|
||||
int i = 0;
|
||||
while (0)
|
||||
{
|
||||
if (cmd[i].command == CMD_END)
|
||||
{
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
int i;
|
||||
|
||||
if (0 != strcmp(cmd[i].name, search))
|
||||
{
|
||||
for (i=0; CMD_END != cmd[i].command; i++)
|
||||
if (0 == strcmp (cmd[i].name, search))
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
|
||||
@ -36,12 +28,11 @@ cmd_find(const struct PERF_TALER_MINTDB_CMD *cmd, const char *search)
|
||||
cmd_init(struct PERF_TALER_MINTDB_CMD cmd[])
|
||||
{
|
||||
int i = 0;
|
||||
while (cmd[i].command != CMD_END)
|
||||
while (CMD_END != cmd[i].command)
|
||||
{
|
||||
switch (cmd[i].command)
|
||||
{
|
||||
case CMD_SAVE_ARRAY:
|
||||
|
||||
// Initialization is done differently depending of the type saved
|
||||
switch (cmd[i].details.save_array.saved_type)
|
||||
{
|
||||
@ -142,7 +133,6 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
{
|
||||
case CMD_END:
|
||||
return GNUNET_YES;
|
||||
break;
|
||||
|
||||
case CMD_LOOP:
|
||||
cmd[i].details.loop.curr_iteration++;
|
||||
@ -294,8 +284,8 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the commands given in cmd, working with
|
||||
* the database referenced by db_plugin
|
||||
* Runs the commands given in @a cmd, working with
|
||||
* the database referenced by @a db_plugin
|
||||
*/
|
||||
int
|
||||
PERF_TALER_MINTDB_interprete(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
|
@ -8,12 +8,18 @@
|
||||
#include <taler/taler_mintdb_plugin.h>
|
||||
|
||||
|
||||
#define INIT_CMD_END(label) {.command = CMD_END, .name = label}
|
||||
|
||||
#define INIT_CMD_LOOP(label, _iter) {.command = CMD_LOOP, .name = label, .details.loop = {.max_iterations = _iter, .curr_iteration = -1} }
|
||||
#define INIT_CMD_LOOP(label, _iter) { \
|
||||
.command = CMD_LOOP, \
|
||||
.name = label, \
|
||||
.details.loop = { \
|
||||
.max_iterations = _iter, \
|
||||
.curr_iteration = -1} \
|
||||
}
|
||||
|
||||
#define INIT_CMD_END_LOOP(label, _loopname) {.command = CMD_END_LOOP, .name = label, .details.end_loop.loop_start = _loopname}
|
||||
|
||||
#define INIT_CMD_END(label) {.command = CMD_END, .name = label}
|
||||
|
||||
#define INIT_CMD_GET_TIME(label) {.command = CMD_GET_TIME, .name = label}
|
||||
|
||||
@ -82,7 +88,7 @@ struct PERF_TALER_MINTDB_CMD{
|
||||
|
||||
} command;
|
||||
|
||||
char name[40];
|
||||
const char *name; // label!
|
||||
|
||||
// Contains command specific data.
|
||||
union {
|
||||
@ -103,15 +109,18 @@ struct PERF_TALER_MINTDB_CMD{
|
||||
} gauger;
|
||||
|
||||
struct {
|
||||
int nb; // Number of deposits to save
|
||||
int index; // The number of deposits already saved
|
||||
/**
|
||||
* Comment!
|
||||
*/
|
||||
unsigned int nb; // Number of deposits to save
|
||||
unsigned int index; // The number of deposits already saved
|
||||
char loop[40]; // The loop from which the data will be extracted
|
||||
char saved[40]; // The deposit saved
|
||||
enum PERF_TALER_MINTDB_TYPE saved_type;
|
||||
union {
|
||||
struct TALER_MINTDB_Deposit **deposit;
|
||||
struct timespec *time;
|
||||
} saved_data;
|
||||
union NAME_IT_TOP_LEVEL {
|
||||
struct TALER_MINTDB_Deposit *deposit;
|
||||
struct timespec time;
|
||||
} *samples;
|
||||
} save_array;
|
||||
|
||||
struct {
|
||||
@ -128,7 +137,7 @@ struct PERF_TALER_MINTDB_CMD{
|
||||
|
||||
|
||||
} details;
|
||||
union {
|
||||
union NAME_IT_TOP_LEVEL {
|
||||
struct TALER_MINTDB_Deposit *deposit;
|
||||
struct timespec time;
|
||||
} exposed;
|
||||
@ -140,7 +149,7 @@ struct PERF_TALER_MINTDB_CMD{
|
||||
int
|
||||
PERF_TALER_MINTDB_interprete(
|
||||
struct TALER_MINTDB_Plugin *db_plugin,
|
||||
struct TALER_MINTDB_Session *session,
|
||||
struct TALER_MINTDB_Session *session, // add START_SESSION CMD
|
||||
struct PERF_TALER_MINTDB_CMD cmd[]);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user