summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <sreeharsha@totakura.in>2015-03-16 11:01:01 +0100
committerSree Harsha Totakura <sreeharsha@totakura.in>2015-03-16 11:08:52 +0100
commitd794a6d53a93970804469c74631b1f41254ac0b7 (patch)
tree17503d180801dab35de56e1e5166b961fe17a53a /src
parent99af8083f5372da59b1d965c63f9be8e750c4aa9 (diff)
downloadexchange-d794a6d53a93970804469c74631b1f41254ac0b7.tar.gz
exchange-d794a6d53a93970804469c74631b1f41254ac0b7.tar.bz2
exchange-d794a6d53a93970804469c74631b1f41254ac0b7.zip
db: implement have_deposit()
Diffstat (limited to 'src')
-rw-r--r--src/mint/mint_db.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/mint/mint_db.c b/src/mint/mint_db.c
index 1a8acaa5f..6ed7193e3 100644
--- a/src/mint/mint_db.c
+++ b/src/mint/mint_db.c
@@ -556,9 +556,11 @@ TALER_MINT_DB_prepare (PGconn *db_conn)
"h_wire,"
"coin_sig"
" FROM deposits WHERE ("
- "coin_pub = $1"
+ "(coin_pub = $1) AND"
+ "(transaction_id = $2) AND"
+ "(merchant_pub = $3)"
")",
- 1, NULL);
+ 3, NULL);
return GNUNET_OK;
#undef PREPARE
}
@@ -1286,13 +1288,16 @@ int
TALER_MINT_DB_have_deposit (PGconn *db_conn,
const struct Deposit *deposit)
{
- // FIXME: check logic!
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR (&deposit->coin.coin_pub), // FIXME
+ TALER_DB_QUERY_PARAM_PTR (&deposit->coin.coin_pub),
+ TALER_DB_QUERY_PARAM_PTR (&deposit->transaction_id),
+ TALER_DB_QUERY_PARAM_PTR (&deposit->merchant_pub),
TALER_DB_QUERY_PARAM_END
};
PGresult *result;
+ int ret;
+ ret = GNUNET_SYSERR;
result = TALER_DB_exec_prepared (db_conn,
"get_deposit",
params);
@@ -1300,16 +1305,19 @@ TALER_MINT_DB_have_deposit (PGconn *db_conn,
PQresultStatus (result))
{
BREAK_DB_ERR (result);
- PQclear (result);
- return GNUNET_SYSERR;
+ goto cleanup;
}
if (0 == PQntuples (result))
{
- PQclear (result);
- return GNUNET_NO;
+ ret = GNUNET_NO;
+ goto cleanup;
}
- return GNUNET_YES;
+ ret = GNUNET_YES;
+
+ cleanup:
+ PQclear (result);
+ return ret;
}