commit ab9b0adb937fc9fb83782a8e812239cc5f67b5b8
parent 11b63a55ac14ab49badb525dea87e790b2f0a4c8
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 10 Apr 2025 18:44:21 +0200
use numeric score for sanction list rating
Diffstat:
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/exchange/taler-exchange-sanctionscheck.c b/src/exchange/taler-exchange-sanctionscheck.c
@@ -142,6 +142,21 @@ shutdown_task (void *cls)
/**
+ * Convert double value @a d to numeric score.
+ *
+ * @param d score from [0,1]
+ * @return value from 0 to 1 billion proportional to @a d
+ */
+static uint64_t
+double_to_billion (double d)
+{
+ GNUNET_break (d >= 0);
+ GNUNET_break (d <= 1.0);
+ return (uint64_t) round (d * 1000000000);
+}
+
+
+/**
* Function called with the result of a sanction evaluation.
*
* @param cls closure
@@ -192,10 +207,10 @@ sanction_cb (void *cls,
properties = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("SANCTION_LIST_BEST_MATCH",
best_match),
- GNUNET_JSON_pack_double ("SANCTION_LIST_RATING",
- rating),
- GNUNET_JSON_pack_double ("SANCTION_LIST_CONFIDENCE",
- confidence),
+ GNUNET_JSON_pack_uint64 ("SANCTION_LIST_RATING",
+ double_to_billion (rating)),
+ GNUNET_JSON_pack_uint64 ("SANCTION_LIST_CONFIDENCE",
+ double_to_billion (confidence)),
GNUNET_JSON_pack_string ("AML_INVESTIGATION_STATE",
"INVESTIGATION_PENDING"),
GNUNET_JSON_pack_string ("AML_INVESTIGATION_TIGGER",