aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/lrbt_callbacks.c
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2022-10-14 18:56:59 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2022-10-14 18:56:59 +0200
commit054e157af8c768062dd0a8e66614da18407fca28 (patch)
treefcd792c6ed7f4384e9b29f8e200f62837cd00f1e /src/exchangedb/lrbt_callbacks.c
parent956e3c3065ddb762dbe01fd720cc5ef403232564 (diff)
WIP: policy_details handling continued
- policy details generated on deposit/batch-deposit requests - insert or update of policy details in the DB - accumulation of amounts of multiple deposits for the same policy_details
Diffstat (limited to 'src/exchangedb/lrbt_callbacks.c')
-rw-r--r--src/exchangedb/lrbt_callbacks.c106
1 files changed, 37 insertions, 69 deletions
diff --git a/src/exchangedb/lrbt_callbacks.c b/src/exchangedb/lrbt_callbacks.c
index 5fe0817e..d24dc688 100644
--- a/src/exchangedb/lrbt_callbacks.c
+++ b/src/exchangedb/lrbt_callbacks.c
@@ -1435,33 +1435,47 @@ lrbt_cb_table_policy_details (void *cls,
unsigned int num_results)
{
struct LookupRecordsByTableContext *ctx = cls;
+ struct PostgresClosure *pg = ctx->pg;
struct TALER_EXCHANGEDB_TableData td = {
.table = TALER_EXCHANGEDB_RT_POLICY_DETAILS
};
for (unsigned int i = 0; i<num_results; i++)
{
- bool no_config = false;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("policy_details_serial_id",
&td.serial),
- GNUNET_PQ_result_spec_auto_from_type ("serial_id",
+ GNUNET_PQ_result_spec_auto_from_type ("hash_code",
&td.details.policy_details.
- serial_id),
+ hash_code),
GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_string ("policy_options",
- &td.details.policy_details.
- policy_options),
- &no_config),
+ TALER_PQ_result_spec_json ("policy_json",
+ &td.details.policy_details.
+ policy_json),
+ &td.details.policy_details.no_policy_json),
GNUNET_PQ_result_spec_timestamp ("deadline",
&td.details.policy_details.
deadline),
- GNUNET_PQ_result_spec_uint16 ("timeout_fulfilment_state",
- &td.details.policy_details.
- timeout_fulfilment_state),
- GNUNET_PQ_result_spec_uint16 ("fulfilment_state",
+ TALER_PQ_RESULT_SPEC_AMOUNT ("commitment",
+ &td.details.policy_details.
+ commitment),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("accumulated_total",
+ &td.details.policy_details.
+ accumulated_total),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("fee",
+ &td.details.policy_details.
+ fee),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("transferable",
+ &td.details.policy_details.
+ transferable),
+ GNUNET_PQ_result_spec_uint16 ("fulfillment_state",
&td.details.policy_details.
- fulfilment_state),
+ fulfillment_state),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_uint64 ("fulfillment_id",
+ &td.details.policy_details.
+ fulfillment_id),
+ &td.details.policy_details.no_fulfillment_id),
GNUNET_PQ_result_spec_end
};
@@ -1482,16 +1496,16 @@ lrbt_cb_table_policy_details (void *cls,
/**
- * Function called with policy_fulfilments table entries.
+ * Function called with policy_fulfillments table entries.
*
* @param cls closure
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
-lrbt_cb_table_policy_fulfilments (void *cls,
- PGresult *result,
- unsigned int num_results)
+lrbt_cb_table_policy_fulfillments (void *cls,
+ PGresult *result,
+ unsigned int num_results)
{
struct LookupRecordsByTableContext *ctx = cls;
struct TALER_EXCHANGEDB_TableData td = {
@@ -1503,17 +1517,17 @@ lrbt_cb_table_policy_fulfilments (void *cls,
bool no_config = false;
bool no_timestamp = false;
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("fulfilment_id",
+ GNUNET_PQ_result_spec_uint64 ("fulfillment_id",
&td.serial),
GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_timestamp ("fulfilment_timestamp",
- &td.details.policy_fulfilments.
- fulfilment_timestamp),
+ GNUNET_PQ_result_spec_timestamp ("fulfillment_timestamp",
+ &td.details.policy_fulfillments.
+ fulfillment_timestamp),
&no_timestamp),
GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_string ("fulfilment_proof",
- &td.details.policy_fulfilments.
- fulfilment_proof),
+ GNUNET_PQ_result_spec_string ("fulfillment_proof",
+ &td.details.policy_fulfillments.
+ fulfillment_proof),
&no_config),
GNUNET_PQ_result_spec_end
};
@@ -1535,52 +1549,6 @@ lrbt_cb_table_policy_fulfilments (void *cls,
/**
- * Function called with policy_details_fulfilments table entries.
- *
- * @param cls closure
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lrbt_cb_table_policy_details_fulfilments (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct LookupRecordsByTableContext *ctx = cls;
- struct TALER_EXCHANGEDB_TableData td = {
- .table = TALER_EXCHANGEDB_RT_POLICY_DETAILS_FULFILMENTS
- };
-
- for (unsigned int i = 0; i<num_results; i++)
- {
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("fulfilment_id",
- &td.details.policy_details_fulfilments.
- fulfilment_id),
- GNUNET_PQ_result_spec_auto_from_type ("serial_id",
- &td.details.
- policy_details_fulfilments.
- serial_id),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ctx->error = true;
- return;
- }
- ctx->cb (ctx->cb_cls,
- &td);
- GNUNET_PQ_cleanup_result (rs);
- }
-}
-
-
-/**
* Function called with purse_requests table entries.
*
* @param cls closure