/*
   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 AUDITOR_DATABASE_ITERATE_EXCHANGE_SIGNKEYS_H
#define AUDITOR_DATABASE_ITERATE_EXCHANGE_SIGNKEYS_H

#include "taler/taler_util.h"
#include "taler/taler_json_lib.h"
#include "auditordb_lib.h"


struct TALER_AUDITORDB_ExchangeSignkeys
{
  uint64_t row_id;
  struct TALER_ExchangePublicKeyP exchange_pub;
  struct TALER_MasterSignatureP master_sig;
  struct GNUNET_TIME_Absolute ep_valid_from;
  struct GNUNET_TIME_Absolute ep_expire_sign;
  struct GNUNET_TIME_Absolute ep_expire_legal;
};

#ifndef TALER_AUDITORDB_EXCHANGE_SIGNKEYS_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_AUDITORDB_ExchangeSignkeysCallback.
 */
#define TALER_AUDITORDB_EXCHANGE_SIGNKEYS_RESULT_CLOSURE void
#endif
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ExchangeSignkeysCallback)(
  TALER_AUDITORDB_EXCHANGE_SIGNKEYS_RESULT_CLOSURE *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_ExchangeSignkeys *dc);


/**
 * Get information about exchange-signkeys from the database.
 *
 * @param pg the database context
 * @param limit number of records to return, negative for descending
 * @param offset table row to start from, exclusive, direction determined by @a limit
 * @param cb function to call with results
 * @param cb_cls closure for @a cb
 * @return query result status
 */
enum GNUNET_DB_QueryStatus
TALER_AUDITORDB_iterate_exchange_signkeys (
  struct TALER_AUDITORDB_PostgresContext *pg,
  int64_t limit,
  uint64_t offset,
  TALER_AUDITORDB_ExchangeSignkeysCallback cb,
  TALER_AUDITORDB_EXCHANGE_SIGNKEYS_RESULT_CLOSURE *cb_cls);

#endif
