/*
  This file is part of Anastasis
  Copyright (C) 2020-2022 Anastasis SARL

  Anastasis is free software; you can redistribute it and/or modify it under the
  terms of the GNU Affero General Public License as published by the Free Software
  Foundation; either version 3, or (at your option) any later version.

  Anastasis 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 Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License along with
  Anastasis; see the file COPYING.GPL.  If not, see <http://www.gnu.org/licenses/>
*/
/**
 * @file include/anastasis/anastasis-database/transaction.h
 * @brief transaction management for the Anastasis database
 * @author Christian Grothoff
 */
#ifndef ANASTASIS_DATABASE_TRANSACTION_H
#define ANASTASIS_DATABASE_TRANSACTION_H

#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_db_lib.h>

/**
 * Check that the database connection is still up.
 */
void
ANASTASIS_DB_check_connection (void);


/**
 * Start a transaction.
 *
 * @param name unique name identifying the transaction (for debugging),
 *             must point to a constant
 * @return #GNUNET_OK on success
 */
enum GNUNET_GenericReturnValue
ANASTASIS_DB_start (const char *name);


/**
 * Roll back the current transaction of the database connection.
 */
void
ANASTASIS_DB_rollback (void);


/**
 * Commit the current transaction of the database connection.
 *
 * @return transaction status code
 */
enum GNUNET_DB_QueryStatus
ANASTASIS_DB_commit (void);

#endif
