diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-10-17 01:48:59 +0200 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-10-17 01:48:59 +0200 |
commit | 448a8be76d41e97222711b83de777e1b332a3964 (patch) | |
tree | a01fb9833c4340223ff446b20e7ab2668b7a4d2e | |
parent | ecce56c052fd3c580d4b85fb2b60270ea51cca0e (diff) |
starting with #4709
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index c53b0a25d..972d70808 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -921,6 +921,29 @@ postgres_prepare (PGconn *db_conn) " )", 3, NULL); + /* Fetch an existing deposit request, used to ensure idempotency + during /deposit processing. Used in #postgres_have_deposit(). */ + PREPARE ("audit_get_deposits_incr", + "SELECT" + " amount_with_fee_val" + ",amount_with_fee_frac" + ",amount_with_fee_curr" + ",timestamp" + ",merchant_pub" + ",coin_pub" + ",coin_sig" + ",transaction_id" + ",refund_deadline" + ",wire_deadline" + ",h_contract" + ",wire" + " FROM deposits" + " WHERE (" + " (deposit_serial_id>=$1)" + " )" + " ORDER BY deposit_serial_id", + 1, NULL); + /* Fetch an existing deposit request. Used in #postgres_wire_lookup_deposit_wtid(). */ PREPARE ("get_deposit_for_wtid", @@ -1407,7 +1430,7 @@ postgres_insert_denomination_info (void *cls, &issue->properties.fee_refresh)); GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency_nbo (&issue->properties.value, - &issue->properties.fee_refund)); + &issue->properties.fee_refund)); result = GNUNET_PQ_exec_prepared (session->conn, "denomination_insert", @@ -4262,6 +4285,40 @@ postgres_select_deposits_above_serial_id (void *cls, TALER_EXCHANGEDB_DepositCallback cb, void *cb_cls) { + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (&serial_id), + GNUNET_PQ_query_param_end + }; + PGresult *result; + result = GNUNET_PQ_exec_prepared (session->conn, + "audit_get_deposits_incr", + params); + if (PGRES_COMMAND_OK != + PQresultStatus (result)) + { + BREAK_DB_ERR (result); + PQclear (result); + return GNUNET_SYSERR; + } + int nrows; + int i; + + nrows = PQntuples (result); + if (0 == nrows) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "audit_get_deposit_incr() returned 0 matching rows\n"); + PQclear (result); + return GNUNET_NO; + } + for (i=0;i<nrows;i++) + { + + } + + PQclear (result); + return GNUNET_OK; + GNUNET_break (0); // FIXME: not implemented return GNUNET_SYSERR; } |