fix aggregator benchmark generation logic

This commit is contained in:
Christian Grothoff 2021-09-04 11:06:37 +02:00
parent 1c1d28d3f5
commit c972925933
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 48 additions and 18 deletions

View File

@ -20,6 +20,7 @@ taler_aggregator_benchmark_SOURCES = \
taler_aggregator_benchmark_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetjson \
-ljansson \

View File

@ -28,6 +28,7 @@
#include "taler_util.h"
#include "taler_signatures.h"
#include "taler_exchangedb_lib.h"
#include "taler_json_lib.h"
#include "taler_error_codes.h"
@ -278,7 +279,7 @@ add_refund (const struct Merchant *m,
RANDOMIZE (&r.details.merchant_sig);
r.details.h_contract_terms = d->h_contract_terms;
r.details.rtransaction_id = 42;
make_amount (0, 9999, &r.details.refund_amount);
make_amount (0, 5000000, &r.details.refund_amount);
make_amount (0, 5, &r.details.refund_fee);
if (0 <=
plugin->insert_refund (plugin->cls,
@ -329,7 +330,7 @@ add_deposit (const struct Merchant *m)
deposit.timestamp = random_time ();
deposit.refund_deadline = random_time ();
deposit.wire_deadline = random_time ();
make_amount (0, 99999, &deposit.amount_with_fee);
make_amount (1, 0, &deposit.amount_with_fee);
make_amount (0, 5, &deposit.deposit_fee);
if (0 >=
plugin->insert_deposit (plugin->cls,
@ -358,10 +359,37 @@ static void
work (void *cls)
{
struct Merchant m;
char *acc;
uint64_t rnd1;
uint64_t rnd2;
(void) cls;
task = NULL;
RANDOMIZE (&m);
rnd1 = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE,
UINT64_MAX);
rnd2 = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE,
UINT64_MAX);
GNUNET_asprintf (&acc,
"payto://aggregator-benchmark/account-%llX-%llX",
(unsigned long long) rnd1,
(unsigned long long) rnd2);
json_wire = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("payto_uri",
acc),
GNUNET_JSON_pack_string ("salt",
"thesalty"));
GNUNET_free (acc);
RANDOMIZE (&m.merchant_pub);
if (GNUNET_OK !=
TALER_JSON_merchant_wire_signature_hash (json_wire,
&m.h_wire))
{
GNUNET_break (0);
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
if (GNUNET_OK !=
plugin->start (plugin->cls,
"aggregator-benchmark-fill"))
@ -394,6 +422,8 @@ work (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to commit, will try again\n");
}
json_decref (json_wire);
json_wire = NULL;
task = GNUNET_SCHEDULER_add_now (&work,
NULL);
}
@ -476,7 +506,7 @@ run (void *cls,
denom_pub.rsa_public_key = pub;
GNUNET_CRYPTO_rsa_public_key_hash (pub,
&h_denom_pub);
make_amountN (1, 0, &issue.properties.value);
make_amountN (2, 0, &issue.properties.value);
make_amountN (0, 5, &issue.properties.fee_withdraw);
make_amountN (0, 5, &issue.properties.fee_deposit);
make_amountN (0, 5, &issue.properties.fee_refresh);
@ -533,11 +563,6 @@ run (void *cls,
}
}
json_wire = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("payto_uri",
"payto://aggregator-benchmark/accountfoo"),
GNUNET_JSON_pack_string ("salt",
"thesalty"));
task = GNUNET_SCHEDULER_add_now (&work,
NULL);
}

View File

@ -817,6 +817,9 @@ run_aggregation (void *cls)
s);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Found %d other deposits to combine into wire transfer.\n",
qs);
/* Subtract wire transfer fee and round to the unit supported by the
wire transfer method; Check if after rounding down, we still have

View File

@ -4636,7 +4636,7 @@ struct MatchingDepositContext
/**
* Set to #GNUNET_SYSERR on hard errors.
*/
int status;
enum GNUNET_GenericReturnValue status;
};
@ -4657,7 +4657,7 @@ match_deposit_cb (void *cls,
struct MatchingDepositContext *mdc = cls;
struct PostgresClosure *pg = mdc->pg;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Found %u/%u matching deposits\n",
num_results,
mdc->limit);
@ -4735,15 +4735,16 @@ postgres_iterate_matching_deposits (
GNUNET_PQ_query_param_auto_from_type (h_wire),
GNUNET_PQ_query_param_end
};
struct MatchingDepositContext mdc;
struct MatchingDepositContext mdc = {
.deposit_cb = deposit_cb,
.deposit_cb_cls = deposit_cb_cls,
.merchant_pub = merchant_pub,
.pg = pg,
.limit = limit,
.status = GNUNET_OK
};
enum GNUNET_DB_QueryStatus qs;
mdc.deposit_cb = deposit_cb;
mdc.deposit_cb_cls = deposit_cb_cls;
mdc.merchant_pub = merchant_pub;
mdc.pg = pg;
mdc.limit = limit;
mdc.status = GNUNET_OK;
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"deposits_iterate_matching",
params,