summaryrefslogtreecommitdiff
path: root/src/exchangedb/perf_select_refunds_by_coin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb/perf_select_refunds_by_coin.c')
-rw-r--r--src/exchangedb/perf_select_refunds_by_coin.c115
1 files changed, 66 insertions, 49 deletions
diff --git a/src/exchangedb/perf_select_refunds_by_coin.c b/src/exchangedb/perf_select_refunds_by_coin.c
index 85c92f4b9..84825d6d7 100644
--- a/src/exchangedb/perf_select_refunds_by_coin.c
+++ b/src/exchangedb/perf_select_refunds_by_coin.c
@@ -33,23 +33,24 @@ static int result;
* Report line of error if @a cond is true, and jump to label "drop".
*/
#define FAILIF(cond) \
- do { \
- if (! (cond)) {break;} \
- GNUNET_break (0); \
- goto drop; \
- } while (0)
+ do { \
+ if (! (cond)) {break;} \
+ GNUNET_break (0); \
+ goto drop; \
+ } while (0)
/**
* Initializes @a ptr with random data.
*/
#define RND_BLK(ptr) \
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr))
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, \
+ sizeof (*ptr))
/**
* Initializes @a ptr with zeros.
*/
#define ZR_BLK(ptr) \
- memset (ptr, 0, sizeof (*ptr))
+ memset (ptr, 0, sizeof (*ptr))
/**
* Currency we use. Must match test-exchange-db-*.conf.
@@ -117,7 +118,7 @@ create_denom_key_pair (unsigned int size,
GNUNET_assert (GNUNET_OK ==
TALER_denom_priv_create (&dkp->priv,
&dkp->pub,
- TALER_DENOMINATION_RSA,
+ GNUNET_CRYPTO_BSA_RSA,
size));
memset (&dki,
0,
@@ -211,21 +212,23 @@ run (void *cls)
struct GNUNET_CONFIGURATION_Handle *cfg = cls;
const uint32_t num_partitions = 10;
struct GNUNET_TIME_Timestamp ts;
- struct TALER_EXCHANGEDB_Deposit *depos = NULL;
+ struct TALER_EXCHANGEDB_CoinDepositInformation *depos = NULL;
struct GNUNET_TIME_Timestamp deadline;
struct TALER_Amount value;
- union TALER_DenominationBlindingKeyP bks;
- struct TALER_CoinPubHashP c_hash;
+ union GNUNET_CRYPTO_BlindingSecretP bks;
struct TALER_EXCHANGEDB_CollectableBlindcoin cbc;
+ struct GNUNET_CRYPTO_BlindingInputValues bi = {
+ .cipher = GNUNET_CRYPTO_BSA_RSA,
+ .rc = 0
+ };
struct TALER_ExchangeWithdrawValues alg_values = {
- .cipher = TALER_DENOMINATION_RSA
+ .blinding_inputs = &bi
};
struct GNUNET_TIME_Relative times = GNUNET_TIME_UNIT_ZERO;
unsigned long long sqrs = 0;
struct TALER_EXCHANGEDB_Refund *ref = NULL;
unsigned int *perm;
unsigned long long duration_sq;
- struct TALER_CoinSpendPublicKeyP coin_pub;
struct TALER_EXCHANGEDB_RefreshRevealedCoin *ccoin;
struct TALER_DenominationPublicKey *new_denom_pubs = NULL;
unsigned int count = 0;
@@ -233,7 +236,7 @@ run (void *cls)
ref = GNUNET_new_array (ROUNDS + 1,
struct TALER_EXCHANGEDB_Refund);
depos = GNUNET_new_array (ROUNDS + 1,
- struct TALER_EXCHANGEDB_Deposit);
+ struct TALER_EXCHANGEDB_CoinDepositInformation);
ZR_BLK (&cbc);
if (NULL ==
@@ -289,7 +292,7 @@ run (void *cls)
for (unsigned int cnt = 0; cnt < MELT_NEW_COINS; cnt++)
{
struct GNUNET_TIME_Timestamp now;
- struct TALER_BlindedRsaPlanchet *rp;
+ struct GNUNET_CRYPTO_RsaBlindedMessage *rp;
struct TALER_BlindedPlanchet *bp;
now = GNUNET_TIME_timestamp_get ();
@@ -301,8 +304,10 @@ run (void *cls)
new_denom_pubs[cnt] = new_dkp[cnt]->pub;
ccoin = &revealed_coins[cnt];
bp = &ccoin->blinded_planchet;
- bp->cipher = TALER_DENOMINATION_RSA;
- rp = &bp->details.rsa_blinded_planchet;
+ bp->blinded_message = GNUNET_new (struct GNUNET_CRYPTO_BlindedMessage);
+ bp->blinded_message->rc = 1;
+ bp->blinded_message->cipher = GNUNET_CRYPTO_BSA_RSA;
+ rp = &bp->blinded_message->details.rsa_blinded_message;
rp->blinded_msg_size = 1 + (size_t) GNUNET_CRYPTO_random_u64 (
GNUNET_CRYPTO_QUALITY_WEAK,
(RSA_KEY_SIZE / 8) - 1);
@@ -321,10 +326,9 @@ run (void *cls)
&new_dkp[cnt]->priv,
true,
bp));
- GNUNET_assert (GNUNET_OK ==
- TALER_coin_ev_hash (bp,
- &cbc.denom_pub_hash,
- &cbc.h_coin_envelope));
+ TALER_coin_ev_hash (bp,
+ &cbc.denom_pub_hash,
+ &cbc.h_coin_envelope);
GNUNET_assert (
GNUNET_OK ==
TALER_denom_sign_blinded (
@@ -344,55 +348,68 @@ run (void *cls)
{
unsigned int i = perm[j];
unsigned int k = (unsigned int) rand () % 5;
+ struct TALER_CoinPubHashP c_hash;
+ uint64_t known_coin_id;
+ struct TALER_EXCHANGEDB_CoinDepositInformation *cdi
+ = &depos[i];
+ struct TALER_EXCHANGEDB_BatchDeposit bd = {
+ .cdis = cdi,
+ .num_cdis = 1,
+ .wallet_timestamp = ts,
+ .refund_deadline = deadline,
+ .wire_deadline = deadline,
+ .receiver_wire_account
+ = "payto://iban/DE67830654080004822650?receiver-name=Test"
+ };
+
if (i >= ROUNDS)
i = ROUNDS; /* throw-away slot, do not keep around */
- RND_BLK (&coin_pub);
+ RND_BLK (&bd.merchant_pub);
+ RND_BLK (&bd.h_contract_terms);
+ RND_BLK (&bd.wire_salt);
+ TALER_merchant_wire_signature_hash (
+ bd.receiver_wire_account,
+ &bd.wire_salt,
+ &h_wire_wt);
+ RND_BLK (&cdi->coin.coin_pub);
+ RND_BLK (&cdi->csig);
RND_BLK (&c_hash);
- depos[i].deposit_fee = fees.deposit;
- RND_BLK (&depos[i].coin.coin_pub);
TALER_denom_pub_hash (&new_dkp[k]->pub,
- &depos[i].coin.denom_pub_hash);
+ &cdi->coin.denom_pub_hash);
GNUNET_assert (GNUNET_OK ==
- TALER_denom_sig_unblind (&depos[i].coin.denom_sig,
+ TALER_denom_sig_unblind (&cdi->coin.denom_sig,
&cbc.sig,
&bks,
&c_hash,
&alg_values,
&new_dkp[k]->pub));
- RND_BLK (&depos[i].merchant_pub);
- RND_BLK (&depos[i].csig);
- RND_BLK (&depos[i].h_contract_terms);
- RND_BLK (&depos[i].wire_salt);
- depos[i].amount_with_fee = value;
- depos[i].refund_deadline = deadline;
- depos[i].wire_deadline = deadline;
- depos[i].receiver_wire_account =
- "payto://iban/DE67830654080004822650?receiver-name=Test";
- TALER_merchant_wire_signature_hash (
- "payto://iban/DE67830654080004822650?receiver-name=Test",
- &depos[i].wire_salt,
- &h_wire_wt);
- depos[i].timestamp = ts;
- uint64_t known_coin_id;
+ cdi->amount_with_fee = value;
+
{
struct TALER_DenominationHashP dph;
struct TALER_AgeCommitmentHash agh;
FAILIF (TALER_EXCHANGEDB_CKS_ADDED !=
plugin->ensure_coin_known (plugin->cls,
- &depos[i].coin,
+ &cdi->coin,
&known_coin_id,
&dph,
&agh));
}
{
struct GNUNET_TIME_Timestamp now;
+ bool balance_ok;
+ uint32_t bad_idx;
+ bool in_conflict;
now = GNUNET_TIME_timestamp_get ();
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->insert_deposit (plugin->cls,
- now,
- &depos[i]));
+ plugin->do_deposit (plugin->cls,
+ &bd,
+ &now,
+ &balance_ok,
+ &bad_idx,
+ &in_conflict));
}
{
bool not_found;
@@ -404,9 +421,9 @@ run (void *cls)
{
case 2: // 100% refund
ref[i].coin = depos[i].coin;
- ref[i].details.merchant_pub = depos[i].merchant_pub;
+ ref[i].details.merchant_pub = bd.merchant_pub;
RND_BLK (&ref[i].details.merchant_sig);
- ref[i].details.h_contract_terms = depos[i].h_contract_terms;
+ ref[i].details.h_contract_terms = bd.h_contract_terms;
ref[i].coin.coin_pub = depos[i].coin.coin_pub;
ref[i].details.rtransaction_id = i;
ref[i].details.refund_amount = value;
@@ -425,9 +442,9 @@ run (void *cls)
if (count < (NUM_ROWS / 10))
{
ref[i].coin = depos[i].coin;
- ref[i].details.merchant_pub = depos[i].merchant_pub;
+ ref[i].details.merchant_pub = bd.merchant_pub;
RND_BLK (&ref[i].details.merchant_sig);
- ref[i].details.h_contract_terms = depos[i].h_contract_terms;
+ ref[i].details.h_contract_terms = bd.h_contract_terms;
ref[i].coin.coin_pub = depos[i].coin.coin_pub;
ref[i].details.rtransaction_id = i;
ref[i].details.refund_amount = value;