added policy_details support into batch_deposit (#7270 related)

This commit is contained in:
Özgür Kesim 2022-11-04 14:00:43 +01:00
parent ac7e0daa2f
commit 680ae81d86
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7

View File

@ -97,6 +97,11 @@ struct BatchDepositContext
*/ */
bool has_policy; 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 * If @e policy_json was present, the corresponding policy extension
* calculates these details. These will be persisted in the policy_details * calculates these details. These will be persisted in the policy_details
@ -105,9 +110,10 @@ struct BatchDepositContext
struct TALER_PolicyDetails policy_details; 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 * Time when this request was generated. Used, for example, to
@ -258,6 +264,21 @@ batch_deposit_transaction (void *cls,
bool balance_ok; bool balance_ok;
bool in_conflict; 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++) for (unsigned int i = 0; i<dc->num_coins; i++)
{ {
const struct TALER_EXCHANGEDB_Deposit *deposit = &dc->deposits[i]; const struct TALER_EXCHANGEDB_Deposit *deposit = &dc->deposits[i];
@ -269,14 +290,18 @@ batch_deposit_transaction (void *cls,
mhd_ret); mhd_ret);
if (qs < 0) if (qs < 0)
return qs; return qs;
qs = TEH_plugin->do_deposit (TEH_plugin->cls,
deposit, qs = TEH_plugin->do_deposit (
known_coin_id, TEH_plugin->cls,
&dc->h_payto, deposit,
false, /* FIXME-OEC: #7270 extension blocked */ known_coin_id,
&dc->exchange_timestamp, &dc->h_payto,
&balance_ok, (dc->has_policy)
&in_conflict); ? &dc->policy_details_serial_id
: NULL,
&dc->exchange_timestamp,
&balance_ok,
&in_conflict);
if (qs < 0) if (qs < 0)
{ {
if (GNUNET_DB_STATUS_SOFT_ERROR == qs) if (GNUNET_DB_STATUS_SOFT_ERROR == qs)