summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2022-11-04 14:00:43 +0100
committerÖzgür Kesim <oec-taler@kesim.org>2022-11-04 14:00:43 +0100
commit680ae81d860eb9bde951a3f95c0da06c111b66f8 (patch)
treecb9afa93f3b6e9a218c21354574526d2f036998b /src/exchange
parentac7e0daa2f78668e7e132b617557290283064485 (diff)
downloadexchange-680ae81d860eb9bde951a3f95c0da06c111b66f8.tar.gz
exchange-680ae81d860eb9bde951a3f95c0da06c111b66f8.tar.bz2
exchange-680ae81d860eb9bde951a3f95c0da06c111b66f8.zip
added policy_details support into batch_deposit (#7270 related)
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_batch-deposit.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c b/src/exchange/taler-exchange-httpd_batch-deposit.c
index 4d4197ab6..cc0e71312 100644
--- a/src/exchange/taler-exchange-httpd_batch-deposit.c
+++ b/src/exchange/taler-exchange-httpd_batch-deposit.c
@@ -98,6 +98,11 @@ struct BatchDepositContext
bool has_policy;
/**
+ * Hash over @e policy_details, might be all zero
+ */
+ struct TALER_ExtensionPolicyHashP h_policy;
+
+ /**
* If @e policy_json was present, the corresponding policy extension
* calculates these details. These will be persisted in the policy_details
* table.
@@ -105,9 +110,10 @@ struct BatchDepositContext
struct TALER_PolicyDetails policy_details;
/**
- * Hash over @e policy_details.
+ * When @e policy_details are persisted, this contains the id of the record
+ * in the policy_details table.
*/
- struct TALER_ExtensionPolicyHashP h_policy;
+ uint64_t policy_details_serial_id;
/**
* Time when this request was generated. Used, for example, to
@@ -258,6 +264,21 @@ batch_deposit_transaction (void *cls,
bool balance_ok;
bool in_conflict;
+ /* If the deposit has a policy associated to it, persist it. This will
+ * insert or update the record. */
+ if (dc->has_policy)
+ {
+ qs = TEH_plugin->persist_policy_details (TEH_plugin->cls,
+ &dc->policy_details,
+ &dc->policy_details_serial_id,
+ &dc->policy_details.
+ accumulated_total,
+ &dc->policy_details.
+ fulfillment_state);
+ if (qs < 0)
+ return qs;
+ }
+
for (unsigned int i = 0; i<dc->num_coins; i++)
{
const struct TALER_EXCHANGEDB_Deposit *deposit = &dc->deposits[i];
@@ -269,14 +290,18 @@ batch_deposit_transaction (void *cls,
mhd_ret);
if (qs < 0)
return qs;
- qs = TEH_plugin->do_deposit (TEH_plugin->cls,
- deposit,
- known_coin_id,
- &dc->h_payto,
- false, /* FIXME-OEC: #7270 extension blocked */
- &dc->exchange_timestamp,
- &balance_ok,
- &in_conflict);
+
+ qs = TEH_plugin->do_deposit (
+ TEH_plugin->cls,
+ deposit,
+ known_coin_id,
+ &dc->h_payto,
+ (dc->has_policy)
+ ? &dc->policy_details_serial_id
+ : NULL,
+ &dc->exchange_timestamp,
+ &balance_ok,
+ &in_conflict);
if (qs < 0)
{
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)