diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2015-11-04 12:04:18 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2015-11-04 12:04:18 +0100 |
commit | 39e4f50b0a0d921f4910d390aaebd93c6a173867 (patch) | |
tree | d342f5a3f1e870a0af29500a7bb05592bb0eac8c /src/backend-lib/merchant_db.c | |
parent | 6e80a32260f1edc4c36e758749dedaf1622cae62 (diff) | |
download | merchant-39e4f50b0a0d921f4910d390aaebd93c6a173867.tar.gz merchant-39e4f50b0a0d921f4910d390aaebd93c6a173867.tar.bz2 merchant-39e4f50b0a0d921f4910d390aaebd93c6a173867.zip |
adding (initial) DB mgmt for deposits
Diffstat (limited to 'src/backend-lib/merchant_db.c')
-rw-r--r-- | src/backend-lib/merchant_db.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/backend-lib/merchant_db.c b/src/backend-lib/merchant_db.c index 3db048db..ed89b1ac 100644 --- a/src/backend-lib/merchant_db.c +++ b/src/backend-lib/merchant_db.c @@ -104,7 +104,12 @@ MERCHANT_DB_initialize (PGconn *conn, int tmp) "contract_id INT8 REFERENCES contracts(contract_id)," "amount INT4 NOT NULL," "amount_fraction INT4 NOT NULL," - "coin_sig BYTEA NOT NULL);", + "coin_sig BYTEA NOT NULL);" + "CREATE %1$s TABLE IF NOT EXISTS deposits (" + "dep_perm TEXT NOT NULL" + "transaction_id INT8 NOT NULL" + "pending INT4 NOT NULL" + "mint_url TEXT NOT NULL);", tmp_str); ret = GNUNET_POSTGRES_exec (conn, sql); (void) GNUNET_POSTGRES_exec (conn, @@ -165,6 +170,16 @@ MERCHANT_DB_initialize (PGconn *conn, int tmp) EXITIF (NULL == (res = PQprepare (conn, + "store_deposit_permission", + "INSERT INTO deposits" + "(dep_perm, transaction_id, pending, mint_url) " + "VALUES ($1, $2, $3, $4);", 4, NULL))); + EXITIF (PGRES_COMMAND_OK != (status = PQresultStatus(res))); + PQclear (res); + + + EXITIF (NULL == (res = PQprepare + (conn, "get_contract_product", "SELECT (" "product" @@ -219,6 +234,22 @@ MERCHANT_DB_initialize (PGconn *conn, int tmp) } +MERCHANT_DB_store_deposit_permission (PGconn *conn, + const char *deposit_permission, + uint64_t transaction_id, + unsigned int pending, + const char *mint_url) +{ + struct TALER_PQ_QueryParam params[] = { + TALER_PQ_query_param_fixed_size (deposit_permission, strlen (deposit_permission)), + TALER_PQ_query_param_uint64 (&transaction_id), + TALER_PQ_query_param_uint32 (&pending), + TALER_PQ_query_param_fixed_size (mint_url, strlen (mint_url)), + TALER_PQ_query_param_end + }; + +} + /** * Insert a contract record into the database and if successfull * return the serial number of the inserted row. |