summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <sreeharsha@totakura.in>2015-03-05 16:31:33 +0100
committerSree Harsha Totakura <sreeharsha@totakura.in>2015-03-05 16:31:33 +0100
commit494e71b9a6e1d6942c758dadda8c8946c99137d2 (patch)
treea0ab7b0d1457bd32a54758b265cbab7f971bc1bf
parent2ac21b63293a3e40ea5903fc2eed158353068611 (diff)
downloadexchange-494e71b9a6e1d6942c758dadda8c8946c99137d2.tar.gz
exchange-494e71b9a6e1d6942c758dadda8c8946c99137d2.tar.bz2
exchange-494e71b9a6e1d6942c758dadda8c8946c99137d2.zip
Use a reserve structure
-rw-r--r--src/mint/mint_db.c24
-rw-r--r--src/mint/mint_db.h32
2 files changed, 39 insertions, 17 deletions
diff --git a/src/mint/mint_db.c b/src/mint/mint_db.c
index b9f30ac3f..e029d0567 100644
--- a/src/mint/mint_db.c
+++ b/src/mint/mint_db.c
@@ -852,25 +852,27 @@ TALER_MINT_DB_commit (PGconn *db_conn)
* Get the summary of a reserve.
*
* @param db the database connection handle
- * @param reserve_pub the public key identifying the reserve
- * @param balance the amount existing in the reserve (will be filled)
- * @param expiry expiration of the reserve (will be filled)
- * @return #GNUNET_OK upon success; #GNUNET_NO when the given reserve is not
- * found; #GNUNET_SYSERR upon failure
+ * @param reserve the reserve data. The public key of the reserve should be set
+ * in this structure; it is used to query the database. The balance
+ * and expiration are then filled accordingly.
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
*/
int
TALER_MINT_DB_reserve_get (PGconn *db,
- struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub,
- struct TALER_Amount *balance,
- struct GNUNET_TIME_Absolute *expiry)
+ struct Reserve *reserve)
{
PGresult *result;
uint64_t expiration_date_nbo;
struct TALER_DB_QueryParam params[] = {
- TALER_DB_QUERY_PARAM_PTR(reserve_pub),
+ TALER_DB_QUERY_PARAM_PTR(reserve->pub),
TALER_DB_QUERY_PARAM_END
};
+ if (NULL == reserve->pub)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
result = TALER_DB_exec_prepared (db,
"get_reserve",
params);
@@ -897,8 +899,8 @@ TALER_MINT_DB_reserve_get (PGconn *db,
"current_balance_value",
"current_balance_fraction",
"current_balance_currency",
- balance));
- expiry->abs_value_us = GNUNET_ntohll (expiration_date_nbo);
+ &reserve->balance));
+ reserve->expiry.abs_value_us = GNUNET_ntohll (expiration_date_nbo);
PQclear (result);
return GNUNET_OK;
diff --git a/src/mint/mint_db.h b/src/mint/mint_db.h
index b80f750b0..b26c70b26 100644
--- a/src/mint/mint_db.h
+++ b/src/mint/mint_db.h
@@ -137,6 +137,27 @@ struct BankTransfer
/* FIXME: add functions to add bank transfers to our DB
(and to test if we already did add one) (#3633) */
+/**
+ * A summary of a Reserve
+ */
+struct Reserve
+{
+ /**
+ * The reserve's public key. This uniquely identifies the reserve
+ */
+ struct GNUNET_CRYPTO_EddsaPublicKey *pub;
+
+ /**
+ * The balance amount existing in the reserve
+ */
+ struct TALER_Amount balance;
+
+ /**
+ * The expiration date of this reserve
+ */
+ struct GNUNET_TIME_Absolute expiry;
+};
+
/**
* Information we keep for a withdrawn coin to reproduce
@@ -173,16 +194,15 @@ struct CollectableBlindcoin
* Get the summary of a reserve.
*
* @param db the database connection handle
- * @param reserve_pub the public key identifying the reserve
- * @param balance the amount existing in the reserve (will be filled)
- * @param expiry expiration of the reserve (will be filled)
+ * @param reserve the reserve data. The public key of the reserve should be set
+ * in this structure; it is used to query the database. The balance
+ * and expiration are then filled accordingly.
* @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
*/
int
TALER_MINT_DB_reserve_get (PGconn *db,
- struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub,
- struct TALER_Amount *balance,
- struct GNUNET_TIME_Absolute *expiry);
+ struct Reserve *reserve);
+
/* FIXME: need call to convert CollectableBlindcoin to JSON (#3527) */