LCOV - code coverage report
Current view: top level - auditor - taler-auditor-httpd_get-monitoring-denomination-pending.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 25 0
Test Date: 2026-04-14 15:39:31 Functions: 0.0 % 2 0

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2024 Taler Systems SA
       4              : 
       5              :    TALER is free software; you can redistribute it and/or modify it under the
       6              :    terms of the GNU General Public License as published by the Free Software
       7              :    Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10              :    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11              :    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12              : 
      13              :    You should have received a copy of the GNU General Public License along with
      14              :    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              :  */
      16              : #include <gnunet/gnunet_util_lib.h>
      17              : #include <gnunet/gnunet_json_lib.h>
      18              : #include <jansson.h>
      19              : #include <microhttpd.h>
      20              : #include <pthread.h>
      21              : #include "taler/taler_json_lib.h"
      22              : #include "taler/taler_mhd_lib.h"
      23              : #include "taler-auditor-httpd.h"
      24              : #include "taler-auditor-httpd_get-monitoring-denomination-pending.h"
      25              : #include "auditor-database/get_denomination_pending.h"
      26              : #include "auditor-database/preflight.h"
      27              : 
      28              : /**
      29              :  * Add denomination-pending to the list.
      30              :  *
      31              :  * @param[in,out] cls a `json_t *` array to extend
      32              :  * @param serial_id location of the @a dc in the database
      33              :  * @param dc struct of inconsistencies
      34              :  * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
      35              :  */
      36              : static enum GNUNET_GenericReturnValue
      37            0 : process_denomination_pending (
      38              :   void *cls,
      39              :   uint64_t serial_id,
      40              :   const struct TALER_AUDITORDB_DenominationPending *dc)
      41              : {
      42            0 :   json_t *list = cls;
      43              :   json_t *obj;
      44              : 
      45            0 :   obj = GNUNET_JSON_PACK (
      46              :     GNUNET_JSON_pack_data_auto ("denom_pub_hash",
      47              :                                 &dc->denom_pub_hash),
      48              :     TALER_JSON_pack_amount ("denom_balance",
      49              :                             &dc->denom_balance),
      50              :     TALER_JSON_pack_amount ("denom_loss",
      51              :                             &dc->denom_loss),
      52              :     GNUNET_JSON_pack_int64 ("num_issued",
      53              :                             dc->num_issued),
      54              :     TALER_JSON_pack_amount ("denom_risk",
      55              :                             &dc->denom_risk),
      56              :     TALER_JSON_pack_amount ("recoup_loss",
      57              :                             &dc->recoup_loss)
      58              :     );
      59            0 :   GNUNET_break (0 ==
      60              :                 json_array_append_new (list,
      61              :                                        obj));
      62            0 :   return GNUNET_OK;
      63              : }
      64              : 
      65              : 
      66              : MHD_RESULT
      67            0 : TAH_get_monitoring_denomination_pending (
      68              :   struct TAH_RequestHandler *rh,
      69              :   struct MHD_Connection *connection,
      70              :   void **connection_cls,
      71              :   const char *upload_data,
      72              :   size_t *upload_data_size,
      73              :   const char *const args[])
      74              : {
      75              :   json_t *ja;
      76              :   enum GNUNET_DB_QueryStatus qs;
      77            0 :   int64_t limit = -20;
      78              :   uint64_t offset;
      79              : 
      80              :   (void) rh;
      81              :   (void) connection_cls;
      82              :   (void) upload_data;
      83              :   (void) upload_data_size;
      84            0 :   if (GNUNET_SYSERR ==
      85            0 :       TALER_AUDITORDB_preflight (TAH_apg))
      86              :   {
      87            0 :     GNUNET_break (0);
      88            0 :     return TALER_MHD_reply_with_error (connection,
      89              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      90              :                                        TALER_EC_GENERIC_DB_SETUP_FAILED,
      91              :                                        NULL);
      92              :   }
      93            0 :   TALER_MHD_parse_request_snumber (connection,
      94              :                                    "limit",
      95              :                                    &limit);
      96            0 :   if (limit < 0)
      97            0 :     offset = INT64_MAX;
      98              :   else
      99            0 :     offset = 0;
     100            0 :   TALER_MHD_parse_request_number (connection,
     101              :                                   "offset",
     102              :                                   &offset);
     103            0 :   ja = json_array ();
     104            0 :   GNUNET_break (NULL != ja);
     105            0 :   qs = TALER_AUDITORDB_get_denomination_pending (
     106              :     TAH_apg,
     107              :     limit,
     108              :     offset,
     109              :     &process_denomination_pending,
     110              :     ja);
     111              : 
     112            0 :   if (0 > qs)
     113              :   {
     114            0 :     GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
     115            0 :     json_decref (ja);
     116            0 :     TALER_LOG_WARNING (
     117              :       "Failed to handle GET /denomination-pending");
     118            0 :     return TALER_MHD_reply_with_error (
     119              :       connection,
     120              :       MHD_HTTP_INTERNAL_SERVER_ERROR,
     121              :       TALER_EC_GENERIC_DB_FETCH_FAILED,
     122              :       "get_denomination_pending");
     123              :   }
     124            0 :   return TALER_MHD_REPLY_JSON_PACK (
     125              :     connection,
     126              :     MHD_HTTP_OK,
     127              :     GNUNET_JSON_pack_array_steal ("denomination_pending",
     128              :                                   ja));
     129              : }
        

Generated by: LCOV version 2.0-1