diff options
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 1dd408752..6ddbead9e 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c | |||
@@ -230,8 +230,7 @@ postgres_create_tables (void *cls) | |||
230 | funds are added and existing funds are withdrawn. The 'expiration_date' | 230 | funds are added and existing funds are withdrawn. The 'expiration_date' |
231 | can be used to eventually get rid of reserves that have not been used | 231 | can be used to eventually get rid of reserves that have not been used |
232 | for a very long time (either by refunding the owner or by greedily | 232 | for a very long time (either by refunding the owner or by greedily |
233 | grabbing the money, depending on the Exchange's terms of service) */ | 233 | grabbing the money, depending on the Exchange's terms of service) */GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS reserves" |
234 | GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS reserves" | ||
235 | "(reserve_pub BYTEA PRIMARY KEY CHECK(LENGTH(reserve_pub)=32)" | 234 | "(reserve_pub BYTEA PRIMARY KEY CHECK(LENGTH(reserve_pub)=32)" |
236 | ",account_details TEXT NOT NULL " | 235 | ",account_details TEXT NOT NULL " |
237 | ",current_balance_val INT8 NOT NULL" | 236 | ",current_balance_val INT8 NOT NULL" |
@@ -292,8 +291,7 @@ postgres_create_tables (void *cls) | |||
292 | The 'h_blind_ev' is the hash of the blinded coin. It serves as a primary | 291 | The 'h_blind_ev' is the hash of the blinded coin. It serves as a primary |
293 | key, as (broken) clients that use a non-random coin and blinding factor | 292 | key, as (broken) clients that use a non-random coin and blinding factor |
294 | should fail to even withdraw, as otherwise the coins will fail to deposit | 293 | should fail to even withdraw, as otherwise the coins will fail to deposit |
295 | (as they really must be unique). */ | 294 | (as they really must be unique). */GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS reserves_out" |
296 | GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS reserves_out" | ||
297 | "(reserve_out_serial_id BIGSERIAL UNIQUE" | 295 | "(reserve_out_serial_id BIGSERIAL UNIQUE" |
298 | ",h_blind_ev BYTEA PRIMARY KEY CHECK (LENGTH(h_blind_ev)=64)" | 296 | ",h_blind_ev BYTEA PRIMARY KEY CHECK (LENGTH(h_blind_ev)=64)" |
299 | ",denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash)" /* do NOT CASCADE on DELETE, we may keep the denomination key alive! */ | 297 | ",denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash)" /* do NOT CASCADE on DELETE, we may keep the denomination key alive! */ |
@@ -341,8 +339,7 @@ postgres_create_tables (void *cls) | |||
341 | index and the index of the new coin, and the envelope of the new | 339 | index and the index of the new coin, and the envelope of the new |
342 | coin to be signed, as well as the encrypted information about the | 340 | coin to be signed, as well as the encrypted information about the |
343 | private key and the blinding factor for the coin (for verification | 341 | private key and the blinding factor for the coin (for verification |
344 | in case this newcoin_index is chosen to be revealed) */ | 342 | in case this newcoin_index is chosen to be revealed) */GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS refresh_revealed_coins " |
345 | GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS refresh_revealed_coins " | ||
346 | "(rc BYTEA NOT NULL REFERENCES refresh_commitments (rc) ON DELETE CASCADE" | 343 | "(rc BYTEA NOT NULL REFERENCES refresh_commitments (rc) ON DELETE CASCADE" |
347 | ",newcoin_index INT4 NOT NULL" | 344 | ",newcoin_index INT4 NOT NULL" |
348 | ",link_sig BYTEA NOT NULL CHECK(LENGTH(link_sig)=64)" | 345 | ",link_sig BYTEA NOT NULL CHECK(LENGTH(link_sig)=64)" |
@@ -797,8 +794,7 @@ postgres_get_session (void *cls) | |||
797 | the coin's denomination information (public key, signature) | 794 | the coin's denomination information (public key, signature) |
798 | and the blinded message as well as the reserve that the coin | 795 | and the blinded message as well as the reserve that the coin |
799 | is being withdrawn from and the signature of the message | 796 | is being withdrawn from and the signature of the message |
800 | authorizing the withdrawal. */ | 797 | authorizing the withdrawal. */GNUNET_PQ_make_prepare ("insert_withdraw_info", |
801 | GNUNET_PQ_make_prepare ("insert_withdraw_info", | ||
802 | "INSERT INTO reserves_out " | 798 | "INSERT INTO reserves_out " |
803 | "(h_blind_ev" | 799 | "(h_blind_ev" |
804 | ",denom_pub_hash" | 800 | ",denom_pub_hash" |
@@ -2207,8 +2203,7 @@ postgres_reserves_in_insert (void *cls, | |||
2207 | Note that for a non-drained reserve we should not switch, | 2203 | Note that for a non-drained reserve we should not switch, |
2208 | as that opens an attack vector for an adversary who can see | 2204 | as that opens an attack vector for an adversary who can see |
2209 | the wire transfer subjects (i.e. when using Bitcoin). | 2205 | the wire transfer subjects (i.e. when using Bitcoin). |
2210 | */ | 2206 | */} |
2211 | } | ||
2212 | 2207 | ||
2213 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2208 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2214 | "Creating reserve %s with expiration in %s\n", | 2209 | "Creating reserve %s with expiration in %s\n", |
@@ -2225,8 +2220,7 @@ postgres_reserves_in_insert (void *cls, | |||
2225 | before adding the actual transaction to "reserves_in", as | 2220 | before adding the actual transaction to "reserves_in", as |
2226 | for a new reserve it can't be a duplicate 'add' operation, | 2221 | for a new reserve it can't be a duplicate 'add' operation, |
2227 | and as the 'add' operation may need the reserve entry | 2222 | and as the 'add' operation may need the reserve entry |
2228 | as a foreign key. */ | 2223 | as a foreign key. */struct GNUNET_PQ_QueryParam params[] = { |
2229 | struct GNUNET_PQ_QueryParam params[] = { | ||
2230 | GNUNET_PQ_query_param_auto_from_type (reserve_pub), | 2224 | GNUNET_PQ_query_param_auto_from_type (reserve_pub), |
2231 | GNUNET_PQ_query_param_string (sender_account_details), | 2225 | GNUNET_PQ_query_param_string (sender_account_details), |
2232 | TALER_PQ_query_param_amount (balance), | 2226 | TALER_PQ_query_param_amount (balance), |
@@ -2283,8 +2277,7 @@ postgres_reserves_in_insert (void *cls, | |||
2283 | balance; we do this after checking for duplication, as | 2277 | balance; we do this after checking for duplication, as |
2284 | otherwise we might have to actually pay the cost to roll this | 2278 | otherwise we might have to actually pay the cost to roll this |
2285 | back for duplicate transactions; like this, we should virtually | 2279 | back for duplicate transactions; like this, we should virtually |
2286 | never actually have to rollback anything. */ | 2280 | never actually have to rollback anything. */struct TALER_EXCHANGEDB_Reserve updated_reserve; |
2287 | struct TALER_EXCHANGEDB_Reserve updated_reserve; | ||
2288 | 2281 | ||
2289 | updated_reserve.pub = reserve.pub; | 2282 | updated_reserve.pub = reserve.pub; |
2290 | if (GNUNET_OK != | 2283 | if (GNUNET_OK != |
@@ -5711,8 +5704,7 @@ postgres_gc (void *cls) | |||
5711 | payback and reserves_out tables to known_coins; these | 5704 | payback and reserves_out tables to known_coins; these |
5712 | are NOT using 'ON DROP CASCADE' and might keep denomination | 5705 | are NOT using 'ON DROP CASCADE' and might keep denomination |
5713 | keys alive for a bit longer, thus causing this statement | 5706 | keys alive for a bit longer, thus causing this statement |
5714 | to fail. */ | 5707 | to fail. */(void) GNUNET_PQ_eval_prepared_non_select (conn, |
5715 | (void) GNUNET_PQ_eval_prepared_non_select (conn, | ||
5716 | "gc_denominations", | 5708 | "gc_denominations", |
5717 | params_time); | 5709 | params_time); |
5718 | GNUNET_PQ_disconnect (conn); | 5710 | GNUNET_PQ_disconnect (conn); |
@@ -7717,4 +7709,5 @@ libtaler_plugin_exchangedb_postgres_done (void *cls) | |||
7717 | return NULL; | 7709 | return NULL; |
7718 | } | 7710 | } |
7719 | 7711 | ||
7712 | |||
7720 | /* end of plugin_exchangedb_postgres.c */ | 7713 | /* end of plugin_exchangedb_postgres.c */ |