/*
   This file is part of TALER
   Copyright (C) 2022 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/>
 */
/**
 * @file src/include/exchange-database/iterate_prewires.h
 * @brief implementation of the iterate_prewires function for Postgres
 * @author Christian Grothoff
 */
#ifndef EXCHANGE_DATABASE_ITERATE_PREWIRES_H
#define EXCHANGE_DATABASE_ITERATE_PREWIRES_H

#include "taler/taler_json_lib.h"
#include "exchangedb_lib.h"


/**
 * Callback with data about a prepared wire transfer.
 *
 * @param cls closure
 * @param rowid row identifier used to mark prepared transaction as done
 * @param wire_method which wire method is this preparation data for
 * @param buf transaction data that was persisted, NULL on error
 * @param buf_size number of bytes in @a buf, 0 on error
 */
typedef void
(*TALER_EXCHANGEDB_WirePreparationIterator) (void *cls,
                                             uint64_t rowid,
                                             const char *wire_method,
                                             const char *buf,
                                             size_t buf_size);

/**
 * Function called to get an unfinished wire transfer
 * preparation data. Fetches at most one item.
 *
 * @param pg the database context
 * @param start_row offset to query table at
 * @param limit maximum number of results to return
 * @param cb function to call for ONE unfinished item
 * @param cb_cls closure for @a cb
 * @return transaction status code
 */
enum GNUNET_DB_QueryStatus
TALER_EXCHANGEDB_iterate_prewires (
  struct TALER_EXCHANGEDB_PostgresContext *pg,
  uint64_t start_row,
  uint64_t limit,
  TALER_EXCHANGEDB_WirePreparationIterator cb,
  void *cb_cls);

#endif
