diff options
Diffstat (limited to 'src/exchangedb/pg_add_policy_fulfillment_proof.c')
-rw-r--r-- | src/exchangedb/pg_add_policy_fulfillment_proof.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/exchangedb/pg_add_policy_fulfillment_proof.c b/src/exchangedb/pg_add_policy_fulfillment_proof.c index bb06206ae..93d070712 100644 --- a/src/exchangedb/pg_add_policy_fulfillment_proof.c +++ b/src/exchangedb/pg_add_policy_fulfillment_proof.c @@ -55,6 +55,7 @@ TEH_PG_add_policy_fulfillment_proof ( enum GNUNET_DB_QueryStatus qs; struct PostgresClosure *pg = cls; size_t count = fulfillment->details_count; + /* FIXME: this seems to be prone to VLA attacks */ struct GNUNET_HashCode hcs[count]; /* Create the sorted policy_hash_codes */ @@ -84,8 +85,7 @@ TEH_PG_add_policy_fulfillment_proof ( GNUNET_PQ_query_param_timestamp (&fulfillment->timestamp), TALER_PQ_query_param_json (fulfillment->proof), GNUNET_PQ_query_param_auto_from_type (&fulfillment->h_proof), - GNUNET_PQ_query_param_fixed_size (hcs, - count * sizeof(struct GNUNET_HashCode)), + TALER_PQ_query_param_array_hash_code (count, hcs, pg->conn), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -94,7 +94,15 @@ TEH_PG_add_policy_fulfillment_proof ( GNUNET_PQ_result_spec_end }; - + PREPARE (pg, + "insert_proof_into_policy_fulfillments", + "INSERT INTO policy_fulfillments" + "(fulfillment_timestamp" + ",fulfillment_proof" + ",h_fulfillment_proof" + ",policy_hash_codes" + ") VALUES ($1, $2, $3, $4)" + " ON CONFLICT DO NOTHING;"); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "insert_proof_into_policy_fulfillments", params, @@ -112,14 +120,28 @@ TEH_PG_add_policy_fulfillment_proof ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&pos->hash_code), GNUNET_PQ_query_param_timestamp (&pos->deadline), - TALER_PQ_query_param_amount (&pos->commitment), - TALER_PQ_query_param_amount (&pos->accumulated_total), - TALER_PQ_query_param_amount (&pos->policy_fee), - TALER_PQ_query_param_amount (&pos->transferable_amount), + TALER_PQ_query_param_amount (pg->conn, + &pos->commitment), + TALER_PQ_query_param_amount (pg->conn, + &pos->accumulated_total), + TALER_PQ_query_param_amount (pg->conn, + &pos->policy_fee), + TALER_PQ_query_param_amount (pg->conn, + &pos->transferable_amount), GNUNET_PQ_query_param_auto_from_type (&pos->fulfillment_state), GNUNET_PQ_query_param_end }; + PREPARE (pg, + "update_policy_details", + "UPDATE policy_details SET" + " deadline=$2" + ",commitment=$3" + ",accumulated_total=$4" + ",fee=$5" + ",transferable=$6" + ",fulfillment_state=$7" + " WHERE policy_hash_code=$1;"); qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "update_policy_details", params); @@ -128,5 +150,10 @@ TEH_PG_add_policy_fulfillment_proof ( } } + /* + * FIXME[oec]-#7999: When all policies of a deposit are fulfilled, + * unblock it and trigger a wire-transfer. + */ + return qs; } |