[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: [policy extensions] mark out wor
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: [policy extensions] mark out work for #7999+#8001 |
Date: |
Wed, 06 Dec 2023 12:37:54 +0100 |
This is an automated email from the git hooks/post-receive script.
oec pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 381c5efb [policy extensions] mark out work for #7999+#8001
381c5efb is described below
commit 381c5efb612e5393bb5a4e85420de8096b95a6e5
Author: Özgür Kesim <oec-taler@kesim.org>
AuthorDate: Wed Dec 6 12:37:51 2023 +0100
[policy extensions] mark out work for #7999+#8001
---
src/exchange/taler-exchange-httpd_extensions.c | 44 ++++++++++++++++++++++--
src/exchangedb/pg_add_policy_fulfillment_proof.c | 10 ++++--
2 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_extensions.c
b/src/exchange/taler-exchange-httpd_extensions.c
index dd0fada7..d62a618a 100644
--- a/src/exchange/taler-exchange-httpd_extensions.c
+++ b/src/exchange/taler-exchange-httpd_extensions.c
@@ -23,6 +23,7 @@
#include "taler-exchange-httpd_keys.h"
#include "taler-exchange-httpd_responses.h"
#include "taler-exchange-httpd_extensions.h"
+#include "taler_extensions_policy.h"
#include "taler_json_lib.h"
#include "taler_mhd_lib.h"
#include "taler_extensions.h"
@@ -256,11 +257,16 @@ policy_fulfillment_transaction (
{
struct TALER_PolicyFulfillmentTransactionData *fulfillment = cls;
+ /* FIXME[oec]: use connection and mhd_ret? */
+ (void) connection;
+ (void) mhd_ret;
+
return TEH_plugin->add_policy_fulfillment_proof (TEH_plugin->cls,
fulfillment);
}
+/* FIXME[oec]-#7999: In this handler: do we transition correctly between
states? */
MHD_RESULT
TEH_extensions_post_handler (
struct TEH_RequestContext *rc,
@@ -338,14 +344,48 @@ TEH_extensions_post_handler (
qs = TEH_plugin->get_policy_details (TEH_plugin->cls,
&hcs[idx],
&policy_details[idx]);
- if (qs < 0)
+ if (0 > qs)
+ {
+ GNUNET_free (hcs);
+ GNUNET_free (policy_details);
+ return TALER_MHD_reply_with_error (rc->connection,
+ MHD_HTTP_BAD_REQUEST,
+
TALER_EC_EXCHANGE_GENERIC_OPERATION_UNKNOWN,
+ "a policy_hash_code couldn't be
found");
+ }
+
+ /* We proceed according to the state of fulfillment */
+ switch (policy_details[idx].fulfillment_state)
{
- error_msg = "a policy_hash_code couldn't be found";
+ case TALER_PolicyFulfillmentReady:
+ break;
+ case TALER_PolicyFulfillmentInsufficient:
+ error_msg = "a policy is not yet fully funded";
+ ret = GNUNET_SYSERR;
+ break;
+ case TALER_PolicyFulfillmentTimeout:
+ error_msg = "a policy is has already timed out";
+ ret = GNUNET_SYSERR;
break;
+ case TALER_PolicyFulfillmentSuccess:
+ /* FIXME[oec]-#8001: Idempotency handling. */
+ GNUNET_break (0);
+ break;
+ case TALER_PolicyFulfillmentFailure:
+ /* FIXME[oec]-#7999: What to do in the failure case? */
+ GNUNET_break (0);
+ break;
+ default:
+ /* Unknown state */
+ GNUNET_assert (0);
}
+
+ if (GNUNET_OK != ret)
+ break;
}
GNUNET_free (hcs);
+
if (GNUNET_OK != ret)
{
GNUNET_free (policy_details);
diff --git a/src/exchangedb/pg_add_policy_fulfillment_proof.c
b/src/exchangedb/pg_add_policy_fulfillment_proof.c
index 0fd6b1c9..93d07071 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[] = {
@@ -132,7 +132,6 @@ TEH_PG_add_policy_fulfillment_proof (
GNUNET_PQ_query_param_end
};
- // FIXME-Oec: review if this is the intended logic here!
PREPARE (pg,
"update_policy_details",
"UPDATE policy_details SET"
@@ -151,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;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: [policy extensions] mark out work for #7999+#8001,
gnunet <=