aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph <Joseph.xu@efrei.net>2022-12-06 07:28:19 -0500
committerJoseph <Joseph.xu@efrei.net>2022-12-06 08:12:07 -0500
commit4b7cb13c32d242bcd364d8f84dfe7fd733c282ee (patch)
treed9cd3ebd001eca2e40da30a42f6dbfd7c839b166
parenta71893d5f2afa9032b30ad73241b87ff4f6a9182 (diff)
some modifications
-rw-r--r--src/exchangedb/pg_batch2_reserves_in_insert.c52
-rw-r--r--src/exchangedb/pg_batch_reserves_in_insert.c2
2 files changed, 35 insertions, 19 deletions
diff --git a/src/exchangedb/pg_batch2_reserves_in_insert.c b/src/exchangedb/pg_batch2_reserves_in_insert.c
index 1e318d10a..8aca11de0 100644
--- a/src/exchangedb/pg_batch2_reserves_in_insert.c
+++ b/src/exchangedb/pg_batch2_reserves_in_insert.c
@@ -64,6 +64,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
struct GNUNET_TIME_Timestamp gc;
struct TALER_PaytoHashP h_payto;
uint64_t reserve_uuid;
+ uint64_t reserve_uuid2;
bool conflicted;
bool conflicted2;
bool transaction_duplicate;
@@ -90,6 +91,7 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
",transaction_duplicate"
",transaction_duplicate2"
",ruuid AS reserve_uuid"
+ ",ruuid2 AS reserve_uuid2"
" FROM batch2_reserves_insert"
" ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21);");
expiry = GNUNET_TIME_absolute_to_timestamp (
@@ -124,45 +126,53 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
notify_s[i] = compute_notify_on_reserve (&reserve->reserve_pub);
}
- for (unsigned int i=0;i<reserves_length;i++)
+ for (unsigned int i=0;i<(reserves_length & ~1);i+=2)
{
- const struct TALER_EXCHANGEDB_ReserveInInfo *reserve = &reserves[i];
+ const struct TALER_EXCHANGEDB_ReserveInInfo *reserve0 = &reserves[i];
+ const struct TALER_EXCHANGEDB_ReserveInInfo *reserve1 = &reserves[i+1];
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (&reserve->reserve_pub),
+ GNUNET_PQ_query_param_auto_from_type (&reserve0->reserve_pub),
GNUNET_PQ_query_param_timestamp (&expiry),
GNUNET_PQ_query_param_timestamp (&gc),
- GNUNET_PQ_query_param_uint64 (&reserve->wire_reference),
- TALER_PQ_query_param_amount (&reserve->balance),
- GNUNET_PQ_query_param_string (reserve->exchange_account_name),
- GNUNET_PQ_query_param_timestamp (&reserve->execution_time),
+ GNUNET_PQ_query_param_uint64 (&reserve0->wire_reference),
+ TALER_PQ_query_param_amount (&reserve0->balance),
+ GNUNET_PQ_query_param_string (reserve0->exchange_account_name),
+ GNUNET_PQ_query_param_timestamp (&reserve0->execution_time),
GNUNET_PQ_query_param_auto_from_type (&h_payto),
- GNUNET_PQ_query_param_string (reserve->sender_account_details),
+ GNUNET_PQ_query_param_string (reserve0->sender_account_details),
GNUNET_PQ_query_param_timestamp (&reserve_expiration),
GNUNET_PQ_query_param_string (notify_s[i]),
- GNUNET_PQ_query_param_auto_from_type (&reserve->reserve_pub),
- GNUNET_PQ_query_param_uint64 (&reserve->wire_reference),
- TALER_PQ_query_param_amount (&reserve->balance),
- GNUNET_PQ_query_param_string (reserve->exchange_account_name),
- GNUNET_PQ_query_param_timestamp (&reserve->execution_time),
+ GNUNET_PQ_query_param_auto_from_type (&reserve1->reserve_pub),
+ GNUNET_PQ_query_param_uint64 (&reserve1->wire_reference),
+ TALER_PQ_query_param_amount (&reserve1->balance),
+ GNUNET_PQ_query_param_string (reserve1->exchange_account_name),
+ GNUNET_PQ_query_param_timestamp (&reserve1->execution_time),
GNUNET_PQ_query_param_auto_from_type (&h_payto),
- GNUNET_PQ_query_param_string (reserve->sender_account_details),
+ GNUNET_PQ_query_param_string (reserve1->sender_account_details),
GNUNET_PQ_query_param_timestamp (&reserve_expiration),
+
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_bool ("conflicted",
&conflicted),
- GNUNET_PQ_result_spec_bool ("conflicted2",
+ GNUNET_PQ_result_spec_bool ("conflicted2",
&conflicted2),
GNUNET_PQ_result_spec_bool ("transaction_duplicate",
&transaction_duplicate),
+ GNUNET_PQ_result_spec_bool ("transaction_duplicate2",
+ &transaction_duplicate2),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
&reserve_uuid),
+ GNUNET_PQ_result_spec_uint64 ("reserve_uuid2",
+ &reserve_uuid2),
GNUNET_PQ_result_spec_end
};
- TALER_payto_hash (reserve->sender_account_details,
+ TALER_payto_hash (reserve0->sender_account_details,
+ &h_payto);
+ TALER_payto_hash (reserve1->sender_account_details,
&h_payto);
/* Note: query uses 'on conflict do nothing' */
@@ -178,14 +188,20 @@ TEH_PG_batch2_reserves_in_insert (void *cls,
qs1);
return qs1;
}
+ if (reserves_length & 1)
+ {
+ const struct TALER_EXCHANGEDB_ReserveInInfo *reserve = &reserves[reserves_length-1];
+ // single insert logic here
+ }
GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs1);
results[i] = (transaction_duplicate)
? GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
: GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
conflicts[i] = conflicted;
conflicts2[i] = conflicted2;
- // fprintf(stdout, "%d", conflicts[i]);
- if (!conflicts[i] && !conflicts2[i]&& transaction_duplicate)
+ // fprintf(stdout, "%d", conflicts[i]);
+ // fprintf(stdout, "%d", conflicts2[i]);
+ if ((!conflicts[i] && transaction_duplicate) ||(!conflicts2[i] && transaction_duplicate2))
{
GNUNET_break (0);
TEH_PG_rollback (pg);
diff --git a/src/exchangedb/pg_batch_reserves_in_insert.c b/src/exchangedb/pg_batch_reserves_in_insert.c
index 2e6487516..8a14022e7 100644
--- a/src/exchangedb/pg_batch_reserves_in_insert.c
+++ b/src/exchangedb/pg_batch_reserves_in_insert.c
@@ -169,7 +169,7 @@ TEH_PG_batch_reserves_in_insert (void *cls,
? GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
: GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
conflicts[i] = conflicted;
- // fprintf(stdout, "%d", conflicts[i]);
+ // fprintf(stdout, "%d", conflicts[i]);
if (!conflicts[i] && transaction_duplicate)
{
GNUNET_break (0);