commit a3bed4aa0c40934e67e51448ae037db9a601d056
parent 89fd00cbe83163c0429e83df608df85169ba334b
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 4 Nov 2025 15:50:47 +0100
implement #9436
Diffstat:
4 files changed, 188 insertions(+), 1 deletion(-)
diff --git a/src/auditor/Makefile.am b/src/auditor/Makefile.am
@@ -199,6 +199,7 @@ taler_auditor_httpd_SOURCES = \
taler-auditor-httpd_bad-sig-losses-get.c taler-auditor-httpd_bad-sig-losses-get.h \
taler-auditor-httpd_closure-lags-get.c taler-auditor-httpd_closure-lags-get.h \
taler-auditor-httpd_progress-get.c taler-auditor-httpd_progress-get.h \
+ taler-auditor-httpd_early-aggregation-get.c taler-auditor-httpd_early-aggregation-get.h \
taler-auditor-httpd_pending-deposits-get.c taler-auditor-httpd_pending-deposits-get.h \
taler-auditor-httpd_reserve-in-inconsistency-get.c taler-auditor-httpd_reserve-in-inconsistency-get.h \
taler-auditor-httpd_reserve-not-closed-inconsistency-get.c taler-auditor-httpd_reserve-not-closed-inconsistency-get.h \
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c
@@ -39,7 +39,8 @@
#include "taler-auditor-httpd_row-inconsistency-get.h"
#include "taler-auditor-httpd_emergency-get.h"
#include "taler-auditor-httpd_emergency-by-count-get.h"
-#include \
+#include "taler-auditor-httpd_early-aggregation-get.h"
+#include \
"taler-auditor-httpd_denomination-key-validity-withdraw-inconsistency-get.h"
#include "taler-auditor-httpd_purse-not-closed-inconsistencies-get.h"
#include "taler-auditor-httpd_reserve-balance-insufficient-inconsistency-get.h"
@@ -353,6 +354,14 @@ handle_mhd_request (void *cls,
.handler = &TAH_pending_deposits_handler_get,
.response_code = MHD_HTTP_OK,
.requires_auth = true },
+ { .url = "/monitoring/early-aggregation",
+ .method = MHD_HTTP_METHOD_GET,
+ .mime_type = "application/json",
+ .data = NULL,
+ .data_size = 0,
+ .handler = &TAH_early_aggregation_handler_get,
+ .response_code = MHD_HTTP_OK,
+ .requires_auth = true },
{ .url = "/monitoring/deposit-confirmation",
.method = MHD_HTTP_METHOD_DELETE,
.mime_type = "application/json",
diff --git a/src/auditor/taler-auditor-httpd_early-aggregation-get.c b/src/auditor/taler-auditor-httpd_early-aggregation-get.c
@@ -0,0 +1,132 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2025 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+#include "taler/platform.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_json_lib.h>
+#include <jansson.h>
+#include <microhttpd.h>
+#include <pthread.h>
+#include "taler/taler_json_lib.h"
+#include "taler/taler_mhd_lib.h"
+#include "taler-auditor-httpd.h"
+#include "taler-auditor-httpd_early-aggregation-get.h"
+
+
+/**
+ * Add early aggregation record to the list.
+ *
+ * @param[in,out] cls a `json_t *` array to extend
+ * @param ea early aggregation record
+ * @return #GNUNET_OK
+ */
+static enum GNUNET_GenericReturnValue
+add_early_aggregation (
+ void *cls,
+ const struct TALER_AUDITORDB_EarlyAggregation *ea)
+{
+ json_t *list = cls;
+ json_t *obj;
+
+ obj = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("row_id",
+ ea->row_id),
+ GNUNET_JSON_pack_uint64 ("batch_deposit_serial_id",
+ ea->batch_deposit_serial_id),
+ GNUNET_JSON_pack_uint64 ("tracking_serial_id",
+ ea->tracking_serial_id),
+ TALER_JSON_pack_amount ("balance",
+ &ea->total),
+ GNUNET_JSON_pack_bool ("suppressed",
+ ea->suppressed)
+ );
+ GNUNET_break (0 ==
+ json_array_append_new (list,
+ obj));
+ return GNUNET_OK;
+}
+
+
+MHD_RESULT
+TAH_early_aggregation_handler_get (
+ struct TAH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size,
+ const char *const args[])
+{
+ json_t *ja;
+ enum GNUNET_DB_QueryStatus qs;
+ int64_t limit = -20;
+ uint64_t offset;
+ bool return_suppressed = false;
+
+ if (GNUNET_SYSERR ==
+ TAH_plugin->preflight (TAH_plugin->cls))
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_SETUP_FAILED,
+ NULL);
+ }
+ TALER_MHD_parse_request_snumber (connection,
+ "limit",
+ &limit);
+ if (limit < 0)
+ offset = INT64_MAX;
+ else
+ offset = 0;
+ TALER_MHD_parse_request_number (connection,
+ "offset",
+ &offset);
+ {
+ const char *ret_s = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "return_suppressed");
+ if ( (NULL != ret_s) &&
+ (0 == strcmp (ret_s,
+ "true")) )
+ {
+ return_suppressed = true;
+ }
+ }
+ ja = json_array ();
+ GNUNET_break (NULL != ja);
+ qs = TAH_plugin->select_early_aggregations (
+ TAH_plugin->cls,
+ limit,
+ offset,
+ return_suppressed,
+ &add_early_aggregation,
+ ja);
+ if (0 > qs)
+ {
+ GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+ json_decref (ja);
+ TALER_LOG_WARNING (
+ "Failed to handle GET /early-aggregation in database\n");
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "select_early_aggregations");
+ }
+ return TALER_MHD_REPLY_JSON_PACK (
+ connection,
+ MHD_HTTP_OK,
+ GNUNET_JSON_pack_array_steal ("early_aggregations",
+ ja));
+}
diff --git a/src/auditor/taler-auditor-httpd_early-aggregation-get.h b/src/auditor/taler-auditor-httpd_early-aggregation-get.h
@@ -0,0 +1,45 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2024 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+#ifndef TALER_AUDITOR_HTTPD_EARLY_AGGREGATION_GET_H
+#define TALER_AUDITOR_HTTPD_EARLY_AGGREGATION_GET_H
+
+#include <gnunet/gnunet_util_lib.h>
+#include <microhttpd.h>
+#include "taler-auditor-httpd.h"
+
+
+/**
+ * Handle a "/monitoring/early-aggregation" request.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param args NULL-terminated array of remaining parts of the URI broken up at '/'
+ * @return MHD result code
+ */
+MHD_RESULT
+TAH_early_aggregation_handler_get (
+ struct TAH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size,
+ const char *const args[]);
+
+
+#endif