/*
* This file is part of GNUnet
* Copyright (C) 2016 GNUnet e.V.
*
* GNUnet 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 of the License,
* or (at your option) any later version.
*
* GNUnet 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file psycstore/plugin_psycstore_postgres.c
* @brief PostgresQL-based psycstore backend
* @author Daniel Golle
* @author Gabor X Toth
* @author Christian Grothoff
* @author Christophe Genevey
* @author Jeffrey Burdges
*/
#include "platform.h"
#include "gnunet_psycstore_plugin.h"
#include "gnunet_psycstore_service.h"
#include "gnunet_multicast_service.h"
#include "gnunet_crypto_lib.h"
#include "gnunet_psyc_util_lib.h"
#include "psycstore.h"
#include "gnunet_pq_lib.h"
/**
* After how many ms "busy" should a DB operation fail for good? A
* low value makes sure that we are more responsive to requests
* (especially PUTs). A high value guarantees a higher success rate
* (SELECTs in iterate can take several seconds despite LIMIT=1).
*
* The default value of 1s should ensure that users do not experience
* huge latencies while at the same time allowing operations to
* succeed with reasonable probability.
*/
#define BUSY_TIMEOUT_MS 1000
#define DEBUG_PSYCSTORE GNUNET_EXTRA_LOGGING
#define LOG(kind,...) GNUNET_log_from (kind, "psycstore-postgres", __VA_ARGS__)
enum Transactions {
TRANSACTION_NONE = 0,
TRANSACTION_STATE_MODIFY,
TRANSACTION_STATE_SYNC,
};
/**
* Context for all functions in this plugin.
*/
struct