-update to latest GNUNET_PQ_make_prepare() API

This commit is contained in:
Christian Grothoff 2022-10-12 14:48:49 +02:00
parent 3036c21283
commit 3b34acdb72
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
8 changed files with 355 additions and 450 deletions

View File

@ -157,28 +157,24 @@ setup_connection (struct PostgresClosure *pg)
struct GNUNET_PQ_PreparedStatement ps[] = { struct GNUNET_PQ_PreparedStatement ps[] = {
/* used in #postgres_commit */ /* used in #postgres_commit */
GNUNET_PQ_make_prepare ("do_commit", GNUNET_PQ_make_prepare ("do_commit",
"COMMIT", "COMMIT"),
0),
/* used in #postgres_insert_exchange */ /* used in #postgres_insert_exchange */
GNUNET_PQ_make_prepare ("auditor_insert_exchange", GNUNET_PQ_make_prepare ("auditor_insert_exchange",
"INSERT INTO auditor_exchanges " "INSERT INTO auditor_exchanges "
"(master_pub" "(master_pub"
",exchange_url" ",exchange_url"
") VALUES ($1,$2);", ") VALUES ($1,$2);"),
2),
/* used in #postgres_delete_exchange */ /* used in #postgres_delete_exchange */
GNUNET_PQ_make_prepare ("auditor_delete_exchange", GNUNET_PQ_make_prepare ("auditor_delete_exchange",
"DELETE" "DELETE"
" FROM auditor_exchanges" " FROM auditor_exchanges"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* used in #postgres_list_exchanges */ /* used in #postgres_list_exchanges */
GNUNET_PQ_make_prepare ("auditor_list_exchanges", GNUNET_PQ_make_prepare ("auditor_list_exchanges",
"SELECT" "SELECT"
" master_pub" " master_pub"
",exchange_url" ",exchange_url"
" FROM auditor_exchanges", " FROM auditor_exchanges"),
0),
/* used in #postgres_insert_exchange_signkey */ /* used in #postgres_insert_exchange_signkey */
GNUNET_PQ_make_prepare ("auditor_insert_exchange_signkey", GNUNET_PQ_make_prepare ("auditor_insert_exchange_signkey",
"INSERT INTO auditor_exchange_signkeys " "INSERT INTO auditor_exchange_signkeys "
@ -188,8 +184,7 @@ setup_connection (struct PostgresClosure *pg)
",ep_end" ",ep_end"
",exchange_pub" ",exchange_pub"
",master_sig" ",master_sig"
") VALUES ($1,$2,$3,$4,$5,$6);", ") VALUES ($1,$2,$3,$4,$5,$6);"),
6),
/* Used in #postgres_insert_deposit_confirmation() */ /* Used in #postgres_insert_deposit_confirmation() */
GNUNET_PQ_make_prepare ("auditor_deposit_confirmation_insert", GNUNET_PQ_make_prepare ("auditor_deposit_confirmation_insert",
"INSERT INTO deposit_confirmations " "INSERT INTO deposit_confirmations "
@ -207,8 +202,7 @@ setup_connection (struct PostgresClosure *pg)
",exchange_sig" ",exchange_sig"
",exchange_pub" ",exchange_pub"
",master_sig" /* master_sig could be normalized... */ ",master_sig" /* master_sig could be normalized... */
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14);", ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14);"),
14),
/* Used in #postgres_get_deposit_confirmations() */ /* Used in #postgres_get_deposit_confirmations() */
GNUNET_PQ_make_prepare ("auditor_deposit_confirmation_select", GNUNET_PQ_make_prepare ("auditor_deposit_confirmation_select",
"SELECT" "SELECT"
@ -228,8 +222,7 @@ setup_connection (struct PostgresClosure *pg)
",master_sig" /* master_sig could be normalized... */ ",master_sig" /* master_sig could be normalized... */
" FROM deposit_confirmations" " FROM deposit_confirmations"
" WHERE master_pub=$1" " WHERE master_pub=$1"
" AND serial_id>$2", " AND serial_id>$2"),
2),
/* Used in #postgres_update_auditor_progress_reserve() */ /* Used in #postgres_update_auditor_progress_reserve() */
GNUNET_PQ_make_prepare ("auditor_progress_update_reserve", GNUNET_PQ_make_prepare ("auditor_progress_update_reserve",
"UPDATE auditor_progress_reserve SET " "UPDATE auditor_progress_reserve SET "
@ -242,8 +235,7 @@ setup_connection (struct PostgresClosure *pg)
",last_account_merges_serial_id=$7" ",last_account_merges_serial_id=$7"
",last_history_requests_serial_id=$8" ",last_history_requests_serial_id=$8"
",last_close_requests_serial_id=$9" ",last_close_requests_serial_id=$9"
" WHERE master_pub=$10", " WHERE master_pub=$10"),
10),
/* Used in #postgres_get_auditor_progress_reserve() */ /* Used in #postgres_get_auditor_progress_reserve() */
GNUNET_PQ_make_prepare ("auditor_progress_select_reserve", GNUNET_PQ_make_prepare ("auditor_progress_select_reserve",
"SELECT" "SELECT"
@ -257,8 +249,7 @@ setup_connection (struct PostgresClosure *pg)
",last_history_requests_serial_id" ",last_history_requests_serial_id"
",last_close_requests_serial_id" ",last_close_requests_serial_id"
" FROM auditor_progress_reserve" " FROM auditor_progress_reserve"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_auditor_progress_reserve() */ /* Used in #postgres_insert_auditor_progress_reserve() */
GNUNET_PQ_make_prepare ("auditor_progress_insert_reserve", GNUNET_PQ_make_prepare ("auditor_progress_insert_reserve",
"INSERT INTO auditor_progress_reserve " "INSERT INTO auditor_progress_reserve "
@ -272,48 +263,41 @@ setup_connection (struct PostgresClosure *pg)
",last_account_merges_serial_id" ",last_account_merges_serial_id"
",last_history_requests_serial_id" ",last_history_requests_serial_id"
",last_close_requests_serial_id" ",last_close_requests_serial_id"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);", ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);"),
10),
/* Used in #postgres_update_auditor_progress_aggregation() */ /* Used in #postgres_update_auditor_progress_aggregation() */
GNUNET_PQ_make_prepare ("auditor_progress_update_aggregation", GNUNET_PQ_make_prepare ("auditor_progress_update_aggregation",
"UPDATE auditor_progress_aggregation SET " "UPDATE auditor_progress_aggregation SET "
" last_wire_out_serial_id=$1" " last_wire_out_serial_id=$1"
" WHERE master_pub=$2", " WHERE master_pub=$2"),
2),
/* Used in #postgres_get_auditor_progress_aggregation() */ /* Used in #postgres_get_auditor_progress_aggregation() */
GNUNET_PQ_make_prepare ("auditor_progress_select_aggregation", GNUNET_PQ_make_prepare ("auditor_progress_select_aggregation",
"SELECT" "SELECT"
" last_wire_out_serial_id" " last_wire_out_serial_id"
" FROM auditor_progress_aggregation" " FROM auditor_progress_aggregation"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_auditor_progress_aggregation() */ /* Used in #postgres_insert_auditor_progress_aggregation() */
GNUNET_PQ_make_prepare ("auditor_progress_insert_aggregation", GNUNET_PQ_make_prepare ("auditor_progress_insert_aggregation",
"INSERT INTO auditor_progress_aggregation " "INSERT INTO auditor_progress_aggregation "
"(master_pub" "(master_pub"
",last_wire_out_serial_id" ",last_wire_out_serial_id"
") VALUES ($1,$2);", ") VALUES ($1,$2);"),
2),
/* Used in #postgres_update_auditor_progress_deposit_confirmation() */ /* Used in #postgres_update_auditor_progress_deposit_confirmation() */
GNUNET_PQ_make_prepare ("auditor_progress_update_deposit_confirmation", GNUNET_PQ_make_prepare ("auditor_progress_update_deposit_confirmation",
"UPDATE auditor_progress_deposit_confirmation SET " "UPDATE auditor_progress_deposit_confirmation SET "
" last_deposit_confirmation_serial_id=$1" " last_deposit_confirmation_serial_id=$1"
" WHERE master_pub=$2", " WHERE master_pub=$2"),
2),
/* Used in #postgres_get_auditor_progress_deposit_confirmation() */ /* Used in #postgres_get_auditor_progress_deposit_confirmation() */
GNUNET_PQ_make_prepare ("auditor_progress_select_deposit_confirmation", GNUNET_PQ_make_prepare ("auditor_progress_select_deposit_confirmation",
"SELECT" "SELECT"
" last_deposit_confirmation_serial_id" " last_deposit_confirmation_serial_id"
" FROM auditor_progress_deposit_confirmation" " FROM auditor_progress_deposit_confirmation"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_auditor_progress_deposit_confirmation() */ /* Used in #postgres_insert_auditor_progress_deposit_confirmation() */
GNUNET_PQ_make_prepare ("auditor_progress_insert_deposit_confirmation", GNUNET_PQ_make_prepare ("auditor_progress_insert_deposit_confirmation",
"INSERT INTO auditor_progress_deposit_confirmation " "INSERT INTO auditor_progress_deposit_confirmation "
"(master_pub" "(master_pub"
",last_deposit_confirmation_serial_id" ",last_deposit_confirmation_serial_id"
") VALUES ($1,$2);", ") VALUES ($1,$2);"),
2),
/* Used in #postgres_update_auditor_progress_coin() */ /* Used in #postgres_update_auditor_progress_coin() */
GNUNET_PQ_make_prepare ("auditor_progress_update_coin", GNUNET_PQ_make_prepare ("auditor_progress_update_coin",
"UPDATE auditor_progress_coin SET " "UPDATE auditor_progress_coin SET "
@ -325,8 +309,7 @@ setup_connection (struct PostgresClosure *pg)
",last_recoup_refresh_serial_id=$6" ",last_recoup_refresh_serial_id=$6"
",last_purse_deposits_serial_id=$7" ",last_purse_deposits_serial_id=$7"
",last_purse_refunds_serial_id=$8" ",last_purse_refunds_serial_id=$8"
" WHERE master_pub=$9", " WHERE master_pub=$9"),
9),
/* Used in #postgres_get_auditor_progress_coin() */ /* Used in #postgres_get_auditor_progress_coin() */
GNUNET_PQ_make_prepare ("auditor_progress_select_coin", GNUNET_PQ_make_prepare ("auditor_progress_select_coin",
"SELECT" "SELECT"
@ -339,8 +322,7 @@ setup_connection (struct PostgresClosure *pg)
",last_purse_deposits_serial_id" ",last_purse_deposits_serial_id"
",last_purse_refunds_serial_id" ",last_purse_refunds_serial_id"
" FROM auditor_progress_coin" " FROM auditor_progress_coin"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_auditor_progress() */ /* Used in #postgres_insert_auditor_progress() */
GNUNET_PQ_make_prepare ("auditor_progress_insert_coin", GNUNET_PQ_make_prepare ("auditor_progress_insert_coin",
"INSERT INTO auditor_progress_coin " "INSERT INTO auditor_progress_coin "
@ -353,8 +335,7 @@ setup_connection (struct PostgresClosure *pg)
",last_recoup_refresh_serial_id" ",last_recoup_refresh_serial_id"
",last_purse_deposits_serial_id" ",last_purse_deposits_serial_id"
",last_purse_refunds_serial_id" ",last_purse_refunds_serial_id"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);", ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9);"),
9),
/* Used in #postgres_insert_wire_auditor_account_progress() */ /* Used in #postgres_insert_wire_auditor_account_progress() */
GNUNET_PQ_make_prepare ("wire_auditor_account_progress_insert", GNUNET_PQ_make_prepare ("wire_auditor_account_progress_insert",
"INSERT INTO wire_auditor_account_progress " "INSERT INTO wire_auditor_account_progress "
@ -364,8 +345,7 @@ setup_connection (struct PostgresClosure *pg)
",last_wire_wire_out_serial_id" ",last_wire_wire_out_serial_id"
",wire_in_off" ",wire_in_off"
",wire_out_off" ",wire_out_off"
") VALUES ($1,$2,$3,$4,$5,$6);", ") VALUES ($1,$2,$3,$4,$5,$6);"),
6),
/* Used in #postgres_update_wire_auditor_account_progress() */ /* Used in #postgres_update_wire_auditor_account_progress() */
GNUNET_PQ_make_prepare ("wire_auditor_account_progress_update", GNUNET_PQ_make_prepare ("wire_auditor_account_progress_update",
"UPDATE wire_auditor_account_progress SET " "UPDATE wire_auditor_account_progress SET "
@ -373,8 +353,7 @@ setup_connection (struct PostgresClosure *pg)
",last_wire_wire_out_serial_id=$2" ",last_wire_wire_out_serial_id=$2"
",wire_in_off=$3" ",wire_in_off=$3"
",wire_out_off=$4" ",wire_out_off=$4"
" WHERE master_pub=$5 AND account_name=$6", " WHERE master_pub=$5 AND account_name=$6"),
6),
/* Used in #postgres_get_wire_auditor_account_progress() */ /* Used in #postgres_get_wire_auditor_account_progress() */
GNUNET_PQ_make_prepare ("wire_auditor_account_progress_select", GNUNET_PQ_make_prepare ("wire_auditor_account_progress_select",
"SELECT" "SELECT"
@ -383,31 +362,27 @@ setup_connection (struct PostgresClosure *pg)
",wire_in_off" ",wire_in_off"
",wire_out_off" ",wire_out_off"
" FROM wire_auditor_account_progress" " FROM wire_auditor_account_progress"
" WHERE master_pub=$1 AND account_name=$2;", " WHERE master_pub=$1 AND account_name=$2;"),
2),
/* Used in #postgres_insert_wire_auditor_progress() */ /* Used in #postgres_insert_wire_auditor_progress() */
GNUNET_PQ_make_prepare ("wire_auditor_progress_insert", GNUNET_PQ_make_prepare ("wire_auditor_progress_insert",
"INSERT INTO wire_auditor_progress " "INSERT INTO wire_auditor_progress "
"(master_pub" "(master_pub"
",last_timestamp" ",last_timestamp"
",last_reserve_close_uuid" ",last_reserve_close_uuid"
") VALUES ($1,$2,$3);", ") VALUES ($1,$2,$3);"),
3),
/* Used in #postgres_update_wire_auditor_progress() */ /* Used in #postgres_update_wire_auditor_progress() */
GNUNET_PQ_make_prepare ("wire_auditor_progress_update", GNUNET_PQ_make_prepare ("wire_auditor_progress_update",
"UPDATE wire_auditor_progress SET " "UPDATE wire_auditor_progress SET "
" last_timestamp=$1" " last_timestamp=$1"
",last_reserve_close_uuid=$2" ",last_reserve_close_uuid=$2"
" WHERE master_pub=$3", " WHERE master_pub=$3"),
3),
/* Used in #postgres_get_wire_auditor_progress() */ /* Used in #postgres_get_wire_auditor_progress() */
GNUNET_PQ_make_prepare ("wire_auditor_progress_select", GNUNET_PQ_make_prepare ("wire_auditor_progress_select",
"SELECT" "SELECT"
" last_timestamp" " last_timestamp"
",last_reserve_close_uuid" ",last_reserve_close_uuid"
" FROM wire_auditor_progress" " FROM wire_auditor_progress"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_reserve_info() */ /* Used in #postgres_insert_reserve_info() */
GNUNET_PQ_make_prepare ("auditor_reserves_insert", GNUNET_PQ_make_prepare ("auditor_reserves_insert",
"INSERT INTO auditor_reserves " "INSERT INTO auditor_reserves "
@ -419,8 +394,7 @@ setup_connection (struct PostgresClosure *pg)
",withdraw_fee_balance_frac" ",withdraw_fee_balance_frac"
",expiration_date" ",expiration_date"
",origin_account" ",origin_account"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);", ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);"),
8),
/* Used in #postgres_update_reserve_info() */ /* Used in #postgres_update_reserve_info() */
GNUNET_PQ_make_prepare ("auditor_reserves_update", GNUNET_PQ_make_prepare ("auditor_reserves_update",
"UPDATE auditor_reserves SET" "UPDATE auditor_reserves SET"
@ -429,8 +403,7 @@ setup_connection (struct PostgresClosure *pg)
",withdraw_fee_balance_val=$3" ",withdraw_fee_balance_val=$3"
",withdraw_fee_balance_frac=$4" ",withdraw_fee_balance_frac=$4"
",expiration_date=$5" ",expiration_date=$5"
" WHERE reserve_pub=$6 AND master_pub=$7;", " WHERE reserve_pub=$6 AND master_pub=$7;"),
7),
/* Used in #postgres_get_reserve_info() */ /* Used in #postgres_get_reserve_info() */
GNUNET_PQ_make_prepare ("auditor_reserves_select", GNUNET_PQ_make_prepare ("auditor_reserves_select",
"SELECT" "SELECT"
@ -442,14 +415,12 @@ setup_connection (struct PostgresClosure *pg)
",auditor_reserves_rowid" ",auditor_reserves_rowid"
",origin_account" ",origin_account"
" FROM auditor_reserves" " FROM auditor_reserves"
" WHERE reserve_pub=$1 AND master_pub=$2;", " WHERE reserve_pub=$1 AND master_pub=$2;"),
2),
/* Used in #postgres_del_reserve_info() */ /* Used in #postgres_del_reserve_info() */
GNUNET_PQ_make_prepare ("auditor_reserves_delete", GNUNET_PQ_make_prepare ("auditor_reserves_delete",
"DELETE" "DELETE"
" FROM auditor_reserves" " FROM auditor_reserves"
" WHERE reserve_pub=$1 AND master_pub=$2;", " WHERE reserve_pub=$1 AND master_pub=$2;"),
2),
/* Used in #postgres_insert_reserve_summary() */ /* Used in #postgres_insert_reserve_summary() */
GNUNET_PQ_make_prepare ("auditor_reserve_balance_insert", GNUNET_PQ_make_prepare ("auditor_reserve_balance_insert",
"INSERT INTO auditor_reserve_balance" "INSERT INTO auditor_reserve_balance"
@ -462,8 +433,7 @@ setup_connection (struct PostgresClosure *pg)
",purse_fee_balance_frac" ",purse_fee_balance_frac"
",history_fee_balance_val" ",history_fee_balance_val"
",history_fee_balance_frac" ",history_fee_balance_frac"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)", ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)"),
9),
/* Used in #postgres_update_reserve_summary() */ /* Used in #postgres_update_reserve_summary() */
GNUNET_PQ_make_prepare ("auditor_reserve_balance_update", GNUNET_PQ_make_prepare ("auditor_reserve_balance_update",
"UPDATE auditor_reserve_balance SET" "UPDATE auditor_reserve_balance SET"
@ -475,8 +445,7 @@ setup_connection (struct PostgresClosure *pg)
",purse_fee_balance_frac=$6" ",purse_fee_balance_frac=$6"
",history_fee_balance_val=$7" ",history_fee_balance_val=$7"
",history_fee_balance_frac=$8" ",history_fee_balance_frac=$8"
" WHERE master_pub=$9;", " WHERE master_pub=$9;"),
9),
/* Used in #postgres_get_reserve_summary() */ /* Used in #postgres_get_reserve_summary() */
GNUNET_PQ_make_prepare ("auditor_reserve_balance_select", GNUNET_PQ_make_prepare ("auditor_reserve_balance_select",
"SELECT" "SELECT"
@ -489,31 +458,27 @@ setup_connection (struct PostgresClosure *pg)
",history_fee_balance_val" ",history_fee_balance_val"
",history_fee_balance_frac" ",history_fee_balance_frac"
" FROM auditor_reserve_balance" " FROM auditor_reserve_balance"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_wire_fee_summary() */ /* Used in #postgres_insert_wire_fee_summary() */
GNUNET_PQ_make_prepare ("auditor_wire_fee_balance_insert", GNUNET_PQ_make_prepare ("auditor_wire_fee_balance_insert",
"INSERT INTO auditor_wire_fee_balance" "INSERT INTO auditor_wire_fee_balance"
"(master_pub" "(master_pub"
",wire_fee_balance_val" ",wire_fee_balance_val"
",wire_fee_balance_frac" ",wire_fee_balance_frac"
") VALUES ($1,$2,$3)", ") VALUES ($1,$2,$3)"),
3),
/* Used in #postgres_update_wire_fee_summary() */ /* Used in #postgres_update_wire_fee_summary() */
GNUNET_PQ_make_prepare ("auditor_wire_fee_balance_update", GNUNET_PQ_make_prepare ("auditor_wire_fee_balance_update",
"UPDATE auditor_wire_fee_balance SET" "UPDATE auditor_wire_fee_balance SET"
" wire_fee_balance_val=$1" " wire_fee_balance_val=$1"
",wire_fee_balance_frac=$2" ",wire_fee_balance_frac=$2"
" WHERE master_pub=$3;", " WHERE master_pub=$3;"),
3),
/* Used in #postgres_get_wire_fee_summary() */ /* Used in #postgres_get_wire_fee_summary() */
GNUNET_PQ_make_prepare ("auditor_wire_fee_balance_select", GNUNET_PQ_make_prepare ("auditor_wire_fee_balance_select",
"SELECT" "SELECT"
" wire_fee_balance_val" " wire_fee_balance_val"
",wire_fee_balance_frac" ",wire_fee_balance_frac"
" FROM auditor_wire_fee_balance" " FROM auditor_wire_fee_balance"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_denomination_balance() */ /* Used in #postgres_insert_denomination_balance() */
GNUNET_PQ_make_prepare ("auditor_denomination_pending_insert", GNUNET_PQ_make_prepare ("auditor_denomination_pending_insert",
"INSERT INTO auditor_denomination_pending " "INSERT INTO auditor_denomination_pending "
@ -529,8 +494,7 @@ setup_connection (struct PostgresClosure *pg)
",recoup_loss_frac" ",recoup_loss_frac"
") VALUES (" ") VALUES ("
"$1,$2,$3,$4,$5,$6,$7,$8,$9,$10" "$1,$2,$3,$4,$5,$6,$7,$8,$9,$10"
");", ");"),
10),
/* Used in #postgres_update_denomination_balance() */ /* Used in #postgres_update_denomination_balance() */
GNUNET_PQ_make_prepare ("auditor_denomination_pending_update", GNUNET_PQ_make_prepare ("auditor_denomination_pending_update",
"UPDATE auditor_denomination_pending SET" "UPDATE auditor_denomination_pending SET"
@ -543,8 +507,7 @@ setup_connection (struct PostgresClosure *pg)
",denom_risk_frac=$7" ",denom_risk_frac=$7"
",recoup_loss_val=$8" ",recoup_loss_val=$8"
",recoup_loss_frac=$9" ",recoup_loss_frac=$9"
" WHERE denom_pub_hash=$10", " WHERE denom_pub_hash=$10"),
10),
/* Used in #postgres_get_denomination_balance() */ /* Used in #postgres_get_denomination_balance() */
GNUNET_PQ_make_prepare ("auditor_denomination_pending_select", GNUNET_PQ_make_prepare ("auditor_denomination_pending_select",
"SELECT" "SELECT"
@ -558,8 +521,7 @@ setup_connection (struct PostgresClosure *pg)
",recoup_loss_val" ",recoup_loss_val"
",recoup_loss_frac" ",recoup_loss_frac"
" FROM auditor_denomination_pending" " FROM auditor_denomination_pending"
" WHERE denom_pub_hash=$1", " WHERE denom_pub_hash=$1"),
1),
/* Used in #postgres_insert_balance_summary() */ /* Used in #postgres_insert_balance_summary() */
GNUNET_PQ_make_prepare ("auditor_balance_summary_insert", GNUNET_PQ_make_prepare ("auditor_balance_summary_insert",
"INSERT INTO auditor_balance_summary " "INSERT INTO auditor_balance_summary "
@ -579,8 +541,7 @@ setup_connection (struct PostgresClosure *pg)
",irregular_recoup_val" ",irregular_recoup_val"
",irregular_recoup_frac" ",irregular_recoup_frac"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10," ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,"
" $11,$12,$13,$14,$15);", " $11,$12,$13,$14,$15);"),
15),
/* Used in #postgres_update_balance_summary() */ /* Used in #postgres_update_balance_summary() */
GNUNET_PQ_make_prepare ("auditor_balance_summary_update", GNUNET_PQ_make_prepare ("auditor_balance_summary_update",
"UPDATE auditor_balance_summary SET" "UPDATE auditor_balance_summary SET"
@ -598,8 +559,7 @@ setup_connection (struct PostgresClosure *pg)
",loss_frac=$12" ",loss_frac=$12"
",irregular_recoup_val=$13" ",irregular_recoup_val=$13"
",irregular_recoup_frac=$14" ",irregular_recoup_frac=$14"
" WHERE master_pub=$15;", " WHERE master_pub=$15;"),
15),
/* Used in #postgres_get_balance_summary() */ /* Used in #postgres_get_balance_summary() */
GNUNET_PQ_make_prepare ("auditor_balance_summary_select", GNUNET_PQ_make_prepare ("auditor_balance_summary_select",
"SELECT" "SELECT"
@ -618,8 +578,7 @@ setup_connection (struct PostgresClosure *pg)
",irregular_recoup_val" ",irregular_recoup_val"
",irregular_recoup_frac" ",irregular_recoup_frac"
" FROM auditor_balance_summary" " FROM auditor_balance_summary"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_historic_denom_revenue() */ /* Used in #postgres_insert_historic_denom_revenue() */
GNUNET_PQ_make_prepare ("auditor_historic_denomination_revenue_insert", GNUNET_PQ_make_prepare ("auditor_historic_denomination_revenue_insert",
"INSERT INTO auditor_historic_denomination_revenue" "INSERT INTO auditor_historic_denomination_revenue"
@ -630,8 +589,7 @@ setup_connection (struct PostgresClosure *pg)
",revenue_balance_frac" ",revenue_balance_frac"
",loss_balance_val" ",loss_balance_val"
",loss_balance_frac" ",loss_balance_frac"
") VALUES ($1,$2,$3,$4,$5,$6,$7);", ") VALUES ($1,$2,$3,$4,$5,$6,$7);"),
7),
/* Used in #postgres_select_historic_denom_revenue() */ /* Used in #postgres_select_historic_denom_revenue() */
GNUNET_PQ_make_prepare ("auditor_historic_denomination_revenue_select", GNUNET_PQ_make_prepare ("auditor_historic_denomination_revenue_select",
"SELECT" "SELECT"
@ -642,8 +600,7 @@ setup_connection (struct PostgresClosure *pg)
",loss_balance_val" ",loss_balance_val"
",loss_balance_frac" ",loss_balance_frac"
" FROM auditor_historic_denomination_revenue" " FROM auditor_historic_denomination_revenue"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_historic_reserve_revenue() */ /* Used in #postgres_insert_historic_reserve_revenue() */
GNUNET_PQ_make_prepare ("auditor_historic_reserve_summary_insert", GNUNET_PQ_make_prepare ("auditor_historic_reserve_summary_insert",
"INSERT INTO auditor_historic_reserve_summary" "INSERT INTO auditor_historic_reserve_summary"
@ -652,8 +609,7 @@ setup_connection (struct PostgresClosure *pg)
",end_date" ",end_date"
",reserve_profits_val" ",reserve_profits_val"
",reserve_profits_frac" ",reserve_profits_frac"
") VALUES ($1,$2,$3,$4,$5);", ") VALUES ($1,$2,$3,$4,$5);"),
5),
/* Used in #postgres_select_historic_reserve_revenue() */ /* Used in #postgres_select_historic_reserve_revenue() */
GNUNET_PQ_make_prepare ("auditor_historic_reserve_summary_select", GNUNET_PQ_make_prepare ("auditor_historic_reserve_summary_select",
"SELECT" "SELECT"
@ -662,8 +618,7 @@ setup_connection (struct PostgresClosure *pg)
",reserve_profits_val" ",reserve_profits_val"
",reserve_profits_frac" ",reserve_profits_frac"
" FROM auditor_historic_reserve_summary" " FROM auditor_historic_reserve_summary"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
/* Used in #postgres_insert_predicted_result() */ /* Used in #postgres_insert_predicted_result() */
GNUNET_PQ_make_prepare ("auditor_predicted_result_insert", GNUNET_PQ_make_prepare ("auditor_predicted_result_insert",
"INSERT INTO auditor_predicted_result" "INSERT INTO auditor_predicted_result"
@ -672,8 +627,7 @@ setup_connection (struct PostgresClosure *pg)
",balance_frac" ",balance_frac"
",drained_val" ",drained_val"
",drained_frac" ",drained_frac"
") VALUES ($1,$2,$3,$4,$5);", ") VALUES ($1,$2,$3,$4,$5);"),
5),
/* Used in #postgres_update_predicted_result() */ /* Used in #postgres_update_predicted_result() */
GNUNET_PQ_make_prepare ("auditor_predicted_result_update", GNUNET_PQ_make_prepare ("auditor_predicted_result_update",
"UPDATE auditor_predicted_result SET" "UPDATE auditor_predicted_result SET"
@ -681,8 +635,7 @@ setup_connection (struct PostgresClosure *pg)
",balance_frac=$2" ",balance_frac=$2"
",drained_val=$3" ",drained_val=$3"
",drained_frac=$4" ",drained_frac=$4"
" WHERE master_pub=$5;", " WHERE master_pub=$5;"),
5),
/* Used in #postgres_get_predicted_balance() */ /* Used in #postgres_get_predicted_balance() */
GNUNET_PQ_make_prepare ("auditor_predicted_result_select", GNUNET_PQ_make_prepare ("auditor_predicted_result_select",
"SELECT" "SELECT"
@ -691,8 +644,7 @@ setup_connection (struct PostgresClosure *pg)
",drained_val" ",drained_val"
",drained_frac" ",drained_frac"
" FROM auditor_predicted_result" " FROM auditor_predicted_result"
" WHERE master_pub=$1;", " WHERE master_pub=$1;"),
1),
GNUNET_PQ_PREPARED_STATEMENT_END GNUNET_PQ_PREPARED_STATEMENT_END
}; };
struct GNUNET_PQ_ExecuteStatement es[] = { struct GNUNET_PQ_ExecuteStatement es[] = {

View File

@ -55,8 +55,12 @@
#include "taler-exchange-httpd_recoup-refresh.h" #include "taler-exchange-httpd_recoup-refresh.h"
#include "taler-exchange-httpd_refreshes_reveal.h" #include "taler-exchange-httpd_refreshes_reveal.h"
#include "taler-exchange-httpd_refund.h" #include "taler-exchange-httpd_refund.h"
#include "taler-exchange-httpd_reserves_attest.h"
#include "taler-exchange-httpd_reserves_close.h"
#include "taler-exchange-httpd_reserves_get.h" #include "taler-exchange-httpd_reserves_get.h"
#include "taler-exchange-httpd_reserves_get_attest.h"
#include "taler-exchange-httpd_reserves_history.h" #include "taler-exchange-httpd_reserves_history.h"
#include "taler-exchange-httpd_reserves_open.h"
#include "taler-exchange-httpd_reserves_purse.h" #include "taler-exchange-httpd_reserves_purse.h"
#include "taler-exchange-httpd_reserves_status.h" #include "taler-exchange-httpd_reserves_status.h"
#include "taler-exchange-httpd_terms.h" #include "taler-exchange-httpd_terms.h"
@ -360,14 +364,14 @@ handle_post_reserves (struct TEH_RequestContext *rc,
ReserveOpHandler handler; ReserveOpHandler handler;
} h[] = { } h[] = {
{
.op = "withdraw",
.handler = &TEH_handler_withdraw
},
{ {
.op = "batch-withdraw", .op = "batch-withdraw",
.handler = &TEH_handler_batch_withdraw .handler = &TEH_handler_batch_withdraw
}, },
{
.op = "withdraw",
.handler = &TEH_handler_withdraw
},
{ {
.op = "status", .op = "status",
.handler = &TEH_handler_reserves_status .handler = &TEH_handler_reserves_status
@ -380,6 +384,18 @@ handle_post_reserves (struct TEH_RequestContext *rc,
.op = "purse", .op = "purse",
.handler = &TEH_handler_reserves_purse .handler = &TEH_handler_reserves_purse
}, },
{
.op = "open",
.handler = &TEH_handler_reserves_open
},
{
.op = "attest",
.handler = &TEH_handler_reserves_attest
},
{
.op = "close",
.handler = &TEH_handler_reserves_close
},
{ {
.op = NULL, .op = NULL,
.handler = NULL .handler = NULL
@ -1038,6 +1054,27 @@ handle_post_auditors (struct TEH_RequestContext *rc,
} }
/**
* Handle a GET "/reserves/$RID/$XXX" request.
*
* @param rc request context
* @param args array of additional options (length: 1, just the reserve_pub)
* @return MHD result code
*/
static MHD_RESULT
handler_reserves_get3 (struct TEH_RequestContext *rc,
const char *const args[3])
{
if (0 == strcmp (args[2],
"attest"))
return TEH_handler_reserves_get_attest (rc,
args);
GNUNET_break_op (0);
return r404 (rc->connection,
"/reserves/$RID/*");
}
/** /**
* Handle incoming HTTP request. * Handle incoming HTTP request.
* *
@ -1151,6 +1188,12 @@ handle_mhd_request (void *cls,
.handler.get = &TEH_handler_reserves_get, .handler.get = &TEH_handler_reserves_get,
.nargs = 1 .nargs = 1
}, },
{
.url = "reserves",
.method = MHD_HTTP_METHOD_GET,
.handler.get = &handler_reserves_get3,
.nargs = 3
},
{ {
.url = "reserves", .url = "reserves",
.method = MHD_HTTP_METHOD_POST, .method = MHD_HTTP_METHOD_POST,

View File

@ -184,12 +184,18 @@ reserve_open_transaction (void *cls,
struct TEH_PurseDepositedCoin *coin = &rsc->payments[i]; struct TEH_PurseDepositedCoin *coin = &rsc->payments[i];
bool insufficient_funds = true; bool insufficient_funds = true;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Make coin %u known\n",
i);
qs = TEH_make_coin_known (&coin->cpi, qs = TEH_make_coin_known (&coin->cpi,
connection, connection,
&coin->known_coin_id, &coin->known_coin_id,
mhd_ret); mhd_ret);
if (qs < 0) if (qs < 0)
return qs; return qs;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Insert open deposit %u known\n",
i);
qs = TEH_plugin->insert_reserve_open_deposit ( qs = TEH_plugin->insert_reserve_open_deposit (
TEH_plugin->cls, TEH_plugin->cls,
&coin->cpi, &coin->cpi,
@ -215,6 +221,8 @@ reserve_open_transaction (void *cls,
} }
if (insufficient_funds) if (insufficient_funds)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Handle insufficient funds\n");
*mhd_ret *mhd_ret
= TEH_RESPONSE_reply_coin_insufficient_funds ( = TEH_RESPONSE_reply_coin_insufficient_funds (
connection, connection,
@ -225,6 +233,8 @@ reserve_open_transaction (void *cls,
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Do reserve open\n");
qs = TEH_plugin->do_reserve_open (TEH_plugin->cls, qs = TEH_plugin->do_reserve_open (TEH_plugin->cls,
/* inputs */ /* inputs */
rsc->reserve_pub, rsc->reserve_pub,
@ -263,6 +273,7 @@ reserve_open_transaction (void *cls,
} }
if (rsc->no_funds) if (rsc->no_funds)
{ {
TEH_plugin->rollback (TEH_plugin->cls);
*mhd_ret *mhd_ret
= TEH_RESPONSE_reply_reserve_insufficient_balance ( = TEH_RESPONSE_reply_reserve_insufficient_balance (
connection, connection,

View File

@ -56,12 +56,12 @@ TEH_PG_do_reserve_open (
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_bool ("out_no_funds",
no_funds),
TALER_PQ_RESULT_SPEC_AMOUNT ("out_open_cost", TALER_PQ_RESULT_SPEC_AMOUNT ("out_open_cost",
open_cost), open_cost),
GNUNET_PQ_result_spec_timestamp ("out_final_expiration", GNUNET_PQ_result_spec_timestamp ("out_final_expiration",
final_expiration), final_expiration),
GNUNET_PQ_result_spec_bool ("out_no_funds",
no_funds),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -73,7 +73,7 @@ TEH_PG_do_reserve_open (
",out_final_expiration" ",out_final_expiration"
",out_no_funds" ",out_no_funds"
" FROM exchange_do_reserve_open" " FROM exchange_do_reserve_open"
" ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);"); " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"do_reserve_open", "do_reserve_open",
params, params,

View File

@ -113,7 +113,7 @@ struct PostgresClosure
if (prep_cnt < pg->prep_gen) \ if (prep_cnt < pg->prep_gen) \
{ \ { \
struct GNUNET_PQ_PreparedStatement ps[] = { \ struct GNUNET_PQ_PreparedStatement ps[] = { \
GNUNET_PQ_make_prepare (name, sql, 0), \ GNUNET_PQ_make_prepare (name, sql), \
GNUNET_PQ_PREPARED_STATEMENT_END \ GNUNET_PQ_PREPARED_STATEMENT_END \
}; \ }; \
\ \

File diff suppressed because it is too large Load Diff

View File

@ -252,6 +252,9 @@ handle_reserves_open_finished (void *cls,
/* This should never happen, either us or the exchange is buggy /* This should never happen, either us or the exchange is buggy
(or API version conflict); just pass JSON reply to the application */ (or API version conflict); just pass JSON reply to the application */
GNUNET_break (0); GNUNET_break (0);
json_dumpf (j,
stderr,
JSON_INDENT (2));
rs.hr.ec = TALER_JSON_get_error_code (j); rs.hr.ec = TALER_JSON_get_error_code (j);
rs.hr.hint = TALER_JSON_get_error_hint (j); rs.hr.hint = TALER_JSON_get_error_hint (j);
break; break;
@ -452,7 +455,7 @@ TALER_EXCHANGE_reserves_open (
cpa), cpa),
TALER_JSON_pack_amount ("reserve_payment", TALER_JSON_pack_amount ("reserve_payment",
reserve_contribution), reserve_contribution),
GNUNET_JSON_pack_uint64 ("min_purses", GNUNET_JSON_pack_uint64 ("purse_limit",
min_purses), min_purses),
GNUNET_JSON_pack_data_auto ("reserve_sig", GNUNET_JSON_pack_data_auto ("reserve_sig",
&roh->reserve_sig)); &roh->reserve_sig));

View File

@ -354,6 +354,70 @@ run (void *cls,
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
struct TALER_TESTING_Command reserves[] = { struct TALER_TESTING_Command reserves[] = {
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-100",
"EUR:1.04"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-100",
"EUR:1.04",
bc.user42_payto,
bc.exchange_payto,
"create-reserve-100"),
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-101",
"EUR:1.04"),
TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-101",
"EUR:1.04",
bc.user42_payto,
bc.exchange_payto,
"create-reserve-101"),
CMD_EXEC_WIREWATCH ("wirewatch-100"),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-100",
"create-reserve-100",
"EUR:1",
0, /* age restriction off */
MHD_HTTP_OK),
TALER_TESTING_cmd_reserve_open ("reserve-open-101-fail",
"create-reserve-101",
"EUR:0",
GNUNET_TIME_UNIT_YEARS,
5, /* min purses */
MHD_HTTP_PAYMENT_REQUIRED, // FIXME: or CONFLICT?
NULL,
NULL),
TALER_TESTING_cmd_reserve_open ("reserve-open-101-ok",
"create-reserve-101",
"EUR:0.01",
GNUNET_TIME_UNIT_MONTHS,
1, /* min purses */
MHD_HTTP_OK,
NULL,
NULL),
TALER_TESTING_cmd_status ("status-101-open-paid",
"create-reserve-101",
"EUR:1.03",
MHD_HTTP_OK),
TALER_TESTING_cmd_reserve_open ("reserve-open-101-ok",
"create-reserve-101",
"EUR:0",
GNUNET_TIME_UNIT_MONTHS,
2, /* min purses */
MHD_HTTP_OK,
"withdraw-coin-100",
"EUR:0.02",
NULL,
NULL),
/* FIXME: use purse quota here */
TALER_TESTING_cmd_reserve_get_attestable ("reserve-101-attestable",
"create-reserve-101",
MHD_HTTP_OK,
NULL),
TALER_TESTING_cmd_reserve_get_attestable ("reserve-101-attest",
"create-reserve-101",
MHD_HTTP_CONFLICT,
"nx-attribute-name",
NULL),
TALER_TESTING_cmd_reserve_close ("reserve-101-close",
"create-reserve-101",
NULL, /* to origin */
MHD_HTTP_OK),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
@ -387,9 +451,11 @@ run (void *cls,
config_file), config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys", TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1), 1),
#if 0
TALER_TESTING_cmd_batch ("reserves", TALER_TESTING_cmd_batch ("reserves",
reserves), reserves),
TALER_TESTING_cmd_end (), // FIXME TALER_TESTING_cmd_end (), // FIXME
#endif
TALER_TESTING_cmd_batch ("withdraw", TALER_TESTING_cmd_batch ("withdraw",
withdraw), withdraw),
TALER_TESTING_cmd_batch ("push", TALER_TESTING_cmd_batch ("push",