diff options
Diffstat (limited to 'src/exchangedb')
| -rw-r--r-- | src/exchangedb/exchange-0001-part.sql | 14 | ||||
| -rw-r--r-- | src/exchangedb/irbt_callbacks.c | 9 | ||||
| -rw-r--r-- | src/exchangedb/lrbt_callbacks.c | 15 | ||||
| -rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 13 | ||||
| -rw-r--r-- | src/exchangedb/procedures.sql | 5 |
5 files changed, 41 insertions, 15 deletions
diff --git a/src/exchangedb/exchange-0001-part.sql b/src/exchangedb/exchange-0001-part.sql index 7e2547db..4a116d12 100644 --- a/src/exchangedb/exchange-0001-part.sql +++ b/src/exchangedb/exchange-0001-part.sql @@ -561,7 +561,8 @@ CREATE TABLE IF NOT EXISTS policy_details ,serial_id BYTEA PRIMARY KEY CHECK(LENGTH(serial_id)=64) ,policy_options VARCHAR ,deadline INT8 NOT NULL - ,fulfilment_state INT4 NOT NULL CHECK(fulfilment_state between 0 and 3)) + ,timeout_fulfilment_state smallint NOT NULL CHECK(timeout_fulfilment_state in (5, 6)) + ,fulfilment_state smallint NOT NULL CHECK(fulfilment_state between 0 and 6)) PARTITION BY HASH (serial_id); COMMENT ON TABLE policy_details IS 'Policies that were provided with deposits via policy extensions.'; @@ -571,8 +572,17 @@ COMMENT ON COLUMN policy_details.policy_options IS 'JSON object with options set that the exchange needs to consider when executing a deposit. Supported details depend on the policy extensions supported by the exchange.'; COMMENT ON COLUMN policy_details.deadline IS 'Deadline until the policy must be marked as fulfilled or unfulfilled (maybe "forever")'; +COMMENT ON COLUMN policy_details.timeout_fulfilment_state + IS 'State that a pending policy should be put into, once the deadline is reached. Allowed values are 5 (TIMEOUT, transfer coins) or 6 (TIMEOUT, coins refreshable)'; COMMENT ON COLUMN policy_details.fulfilment_state - IS 'State of the fulfilment: 0 (PENDING), 1 (FULFILLED), 2 (NOT FULFILLED), 3 (TIMED OUT)'; + IS 'State of the fulfilment: + - 0 (PENDING) + - 1 (SUCCESS, transfer coins) + - 2 (SUCCESS, coins refreshable) + - 3 (FAILURE, transfer coins) + - 4 (FAILURE, coins refreshable) + - 5 (TIMEOUT, tranfer coins) + - 6 (TIMEOUT, coins refrehsable)'; CREATE TABLE IF NOT EXISTS policy_details_default PARTITION OF policy_details diff --git a/src/exchangedb/irbt_callbacks.c b/src/exchangedb/irbt_callbacks.c index 7c494418..e9cce43c 100644 --- a/src/exchangedb/irbt_callbacks.c +++ b/src/exchangedb/irbt_callbacks.c @@ -929,11 +929,16 @@ irbt_cb_table_policy_details (struct PostgresClosure *pg, { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&td->serial), - NULL == - td->details.policy_details.policy_options ? + NULL == td->details.policy_details.policy_options ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string ( td->details.policy_details.policy_options), + GNUNET_PQ_query_param_timestamp ( + &td->details.policy_details.deadline), + GNUNET_PQ_query_param_uint16 ( + &td->details.policy_details.timeout_fulfilment_state), + GNUNET_PQ_query_param_uint16 ( + &td->details.policy_details.fulfilment_state), GNUNET_PQ_query_param_end }; diff --git a/src/exchangedb/lrbt_callbacks.c b/src/exchangedb/lrbt_callbacks.c index a2c654f4..5fe0817e 100644 --- a/src/exchangedb/lrbt_callbacks.c +++ b/src/exchangedb/lrbt_callbacks.c @@ -1456,7 +1456,10 @@ lrbt_cb_table_policy_details (void *cls, GNUNET_PQ_result_spec_timestamp ("deadline", &td.details.policy_details. deadline), - GNUNET_PQ_result_spec_uint64 ("fulfilment_state", + GNUNET_PQ_result_spec_uint16 ("timeout_fulfilment_state", + &td.details.policy_details. + timeout_fulfilment_state), + GNUNET_PQ_result_spec_uint16 ("fulfilment_state", &td.details.policy_details. fulfilment_state), GNUNET_PQ_result_spec_end @@ -1503,15 +1506,15 @@ lrbt_cb_table_policy_fulfilments (void *cls, GNUNET_PQ_result_spec_uint64 ("fulfilment_id", &td.serial), GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_string ("fulfilment_proof", - &td.details.policy_fulfilments. - fulfilment_proof), - &no_config), - GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_timestamp ("fulfilment_timestamp", &td.details.policy_fulfilments. fulfilment_timestamp), &no_timestamp), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_string ("fulfilment_proof", + &td.details.policy_fulfilments. + fulfilment_proof), + &no_config), GNUNET_PQ_result_spec_end }; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index ebac70ea..415417cb 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -822,8 +822,8 @@ prepare_statements (struct PostgresClosure *pg) ",out_balance_ok AS balance_ok" ",out_conflict AS conflicted" " FROM exchange_do_deposit" - " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19);", - 19), + " ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20);", + 20), /* used in postgres_do_purse_deposit() */ GNUNET_PQ_make_prepare ( "call_purse_deposit", @@ -3933,10 +3933,11 @@ prepare_statements (struct PostgresClosure *pg) ",serial_id" ",policy_options" ",deadline" + ",timeout_fulfilment_state" ",fulfilment_state" ") VALUES " - "($1, $2, $3, $4, $5);", - 5), + "($1, $2, $3, $4, $5, $6);", + 6), GNUNET_PQ_make_prepare ( "insert_into_table_policy_fulfilments", "INSERT INTO policy_fulfilments" @@ -6292,6 +6293,9 @@ postgres_do_deposit ( (deposit->has_policy_details) ? GNUNET_PQ_query_param_timestamp (&deposit->policy_deadline) : GNUNET_PQ_query_param_null (), + (deposit->has_policy_details) + ? GNUNET_PQ_query_param_uint16 (&deposit->policy_state_on_timeout) + : GNUNET_PQ_query_param_null (), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -14651,6 +14655,7 @@ postgres_insert_records_by_table (void *cls, case TALER_EXCHANGEDB_RT_POLICY_DETAILS: rh = &irbt_cb_table_policy_details; break; + /* TODO: policy_details_fulfilments and policy_fulfilments */ case TALER_EXCHANGEDB_RT_PURSE_REQUESTS: rh = &irbt_cb_table_purse_requests; break; diff --git a/src/exchangedb/procedures.sql b/src/exchangedb/procedures.sql index 3d49bab1..aeed5de0 100644 --- a/src/exchangedb/procedures.sql +++ b/src/exchangedb/procedures.sql @@ -513,7 +513,8 @@ CREATE OR REPLACE FUNCTION exchange_do_deposit( IN in_policy_blocked BOOLEAN, IN in_policy_details VARCHAR, IN in_policy_serial_id BYTEA, - IN in_policy_deadline INT8, + IN in_policy_deadline SMALLINT, + IN in_policy_timeout_fulfilment_state SMALLINT, OUT out_exchange_timestamp INT8, OUT out_balance_ok BOOLEAN, OUT out_conflict BOOLEAN) @@ -535,11 +536,13 @@ THEN (serial_id ,policy_options ,deadline + ,timeout_fulfilment_state ,fulfilment_state) VALUES (in_policy_serial_id ,in_policy_details ,in_policy_deadline + ,in_policy_timeout_fulfilment_state ,0) -- 0 == pending RETURNING policy_details_serial_id INTO xdi; ELSE |
