refactor: extensions_ -> policy_; added policy_fulfilment
This commit is contained in:
parent
dd60d9b984
commit
52106eea42
@ -113,7 +113,8 @@ static struct Table tables[] = {
|
||||
{ .rt = TALER_EXCHANGEDB_RT_RECOUP},
|
||||
{ .rt = TALER_EXCHANGEDB_RT_RECOUP_REFRESH },
|
||||
{ .rt = TALER_EXCHANGEDB_RT_EXTENSIONS},
|
||||
{ .rt = TALER_EXCHANGEDB_RT_EXTENSION_DETAILS },
|
||||
{ .rt = TALER_EXCHANGEDB_RT_POLICY_DETAILS },
|
||||
{ .rt = TALER_EXCHANGEDB_RT_POLICY_FULFILMENTS },
|
||||
{ .rt = TALER_EXCHANGEDB_RT_PURSE_REQUESTS},
|
||||
{ .rt = TALER_EXCHANGEDB_RT_PURSE_REFUNDS},
|
||||
{ .rt = TALER_EXCHANGEDB_RT_PURSE_MERGES},
|
||||
|
@ -170,23 +170,6 @@ deposit_transaction (void *cls,
|
||||
if (qs < 0)
|
||||
return qs;
|
||||
|
||||
/* Check and apply policies, if applicable */
|
||||
if (NULL != dc->policy_extension)
|
||||
{
|
||||
const struct TALER_Extension *ext = dc->policy_extension;
|
||||
struct TALER_ExtensionsPolicySerialID serialID;
|
||||
struct GNUNET_TIME_Timestamp deadline;
|
||||
GNUNET_assert (ext->parse_policy_details);
|
||||
|
||||
qs = ext->parse_policy_details (dc->deposit->policy_details,
|
||||
&serialID,
|
||||
&deadline);
|
||||
|
||||
if (qs < 0)
|
||||
return qs;
|
||||
|
||||
blocked_by_policy = true;
|
||||
}
|
||||
|
||||
qs = TEH_plugin->do_deposit (TEH_plugin->cls,
|
||||
dc->deposit,
|
||||
@ -351,6 +334,39 @@ TEH_handler_deposit (struct MHD_Connection *connection,
|
||||
&h_wire);
|
||||
dc.deposit = &deposit;
|
||||
|
||||
/* TODO: extract policy information */
|
||||
#if 0
|
||||
if (! deposit.no_policy_details)
|
||||
{
|
||||
const struct TALER_Extension *ext;
|
||||
struct TALER_ExtensionsPolicySerialID serialID;
|
||||
struct GNUNET_TIME_Timestamp deadline;
|
||||
enum GNUNET_GenericReturnValue ret;
|
||||
GNUNET_assert (ext->parse_policy_details);
|
||||
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||
"DEBUG calling parse_policy_details on extension '%s' with details '%s'\n",
|
||||
ext->name,
|
||||
json_dumps (dc->deposit->policy_details, JSON_INDENT (2)));
|
||||
|
||||
ret = ext->parse_policy_details (dc->deposit->policy_details,
|
||||
&serialID,
|
||||
&deadline);
|
||||
|
||||
if (GNUNET_OK != ret)
|
||||
{
|
||||
TALER_LOG_WARNING ("Failed to parse policy details\n");
|
||||
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||
TALER_EC_GENERIC_DB_STORE_FAILED,
|
||||
"deposit");
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
blocked_by_policy = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* new deposit */
|
||||
dc.exchange_timestamp = GNUNET_TIME_timestamp_get ();
|
||||
/* check denomination exists and is valid */
|
||||
|
@ -885,8 +885,8 @@ BEGIN
|
||||
',wire_salt BYTEA NOT NULL CHECK (LENGTH(wire_salt)=16)'
|
||||
',wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=32)'
|
||||
',done BOOLEAN NOT NULL DEFAULT FALSE'
|
||||
',extension_blocked BOOLEAN NOT NULL DEFAULT FALSE'
|
||||
',extension_details_serial_id INT8' -- REFERENCES extension_details (extension_details_serial_id) ON DELETE CASCADE'
|
||||
',policy_blocked BOOLEAN NOT NULL DEFAULT FALSE'
|
||||
',policy_details_serial_id INT8' -- REFERENCES policy_details (policy_details_serial_id) ON DELETE CASCADE'
|
||||
') %s ;'
|
||||
,table_name
|
||||
,'PARTITION BY HASH (coin_pub)'
|
||||
@ -2617,7 +2617,7 @@ BEGIN
|
||||
|
||||
ALTER TABLE IF EXISTS deposits
|
||||
DROP CONSTRAINT IF EXISTS deposits_pkey CASCADE
|
||||
,DROP CONSTRAINT IF EXISTS deposits_extension_details_serial_id_fkey
|
||||
,DROP CONSTRAINT IF EXISTS deposits_policy_details_serial_id_fkey
|
||||
,DROP CONSTRAINT IF EXISTS deposits_coin_pub_merchant_pub_h_contract_terms_key CASCADE
|
||||
;
|
||||
|
||||
|
@ -432,14 +432,14 @@ COMMENT ON TABLE signkey_revocations
|
||||
CREATE TABLE IF NOT EXISTS extensions
|
||||
(extension_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
|
||||
,name VARCHAR NOT NULL UNIQUE
|
||||
,config BYTEA
|
||||
,manifest BYTEA
|
||||
);
|
||||
COMMENT ON TABLE extensions
|
||||
IS 'Configurations of the activated extensions';
|
||||
COMMENT ON COLUMN extensions.name
|
||||
IS 'Name of the extension';
|
||||
COMMENT ON COLUMN extensions.config
|
||||
IS 'Configuration of the extension as JSON-blob, maybe NULL';
|
||||
COMMENT ON COLUMN extensions.manifest
|
||||
IS 'Manifest of the extension as JSON-blob, maybe NULL';
|
||||
|
||||
|
||||
-- ------------------------------ known_coins ----------------------------------------
|
||||
@ -536,22 +536,46 @@ CREATE TABLE IF NOT EXISTS refresh_transfer_keys_default
|
||||
SELECT add_constraints_to_refresh_transfer_keys_partition('default');
|
||||
|
||||
|
||||
-- ------------------------------ extension_details ----------------------------------------
|
||||
-- ------------------------------ policy_fulfilments -------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS extension_details
|
||||
(extension_details_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
|
||||
,extension_options VARCHAR)
|
||||
PARTITION BY HASH (extension_details_serial_id);
|
||||
COMMENT ON TABLE extension_details
|
||||
IS 'Extensions that were provided with deposits (not yet used).';
|
||||
COMMENT ON COLUMN extension_details.extension_options
|
||||
IS 'JSON object with options set that the exchange needs to consider when executing a deposit. Supported details depend on the extensions supported by the exchange.';
|
||||
CREATE TABLE IF NOT EXISTS policy_fulfilments
|
||||
(policy_fulfilments_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
|
||||
,fulfilment_timestamp INT8 NOT NULL
|
||||
,fulfilment_proof VARCHAR)
|
||||
PARTITION BY HASH (policy_fulfilments_serial_id);
|
||||
COMMENT ON TABLE policy_fulfilments
|
||||
IS 'Proofs of fulfilment of policies that were set in deposits';
|
||||
COMMENT ON COLUMN policy_fulfilments.fulfilment_timestamp
|
||||
IS 'Timestamp of the arrival of a proof of fulfilment';
|
||||
COMMENT ON COLUMN policy_fulfilments.fulfilment_proof
|
||||
IS 'JSON object with a proof of the fulfilment of a policy. Supported details depend on the policy extensions supported by the exchange.';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS extension_details_default
|
||||
PARTITION OF extension_details
|
||||
CREATE TABLE IF NOT EXISTS policy_fulfilments_default
|
||||
PARTITION OF policy_fulfilments
|
||||
FOR VALUES WITH (MODULUS 1, REMAINDER 0);
|
||||
|
||||
|
||||
-- ------------------------------ policy_details ----------------------------------------
|
||||
|
||||
CREATE TABLE IF NOT EXISTS policy_details
|
||||
(policy_details_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY
|
||||
,serial_id BYTEA PRIMARY KEY CHECK(LENGTH(serial_id)=64)
|
||||
,policy_options VARCHAR
|
||||
,fulfilment_serial_id BIGINT REFERENCES policy_fulfilments(policy_fulfilments_serial_id) ON DELETE CASCADE)
|
||||
PARTITION BY HASH (serial_id);
|
||||
COMMENT ON TABLE policy_details
|
||||
IS 'Policies that were provided with deposits via policy extensions.';
|
||||
COMMENT ON COLUMN policy_details.serial_id
|
||||
IS 'ID (GNUNET_HashCode) that identifies a policy. Will be calculated by the policy extension based on the content';
|
||||
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.fulfilment_serial_id
|
||||
IS 'If not NULL, refers to the proof of fulfilment of this policy';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS policy_details_default
|
||||
PARTITION OF policy_details
|
||||
FOR VALUES WITH (MODULUS 1, REMAINDER 0);
|
||||
|
||||
-- ------------------------------ deposits ----------------------------------------
|
||||
|
||||
SELECT create_table_deposits();
|
||||
@ -568,10 +592,10 @@ COMMENT ON COLUMN deposits.wire_salt
|
||||
IS 'Salt used when hashing the payto://-URI to get the h_wire';
|
||||
COMMENT ON COLUMN deposits.done
|
||||
IS 'Set to TRUE once we have included this deposit in some aggregate wire transfer to the merchant';
|
||||
COMMENT ON COLUMN deposits.extension_blocked
|
||||
IS 'True if the aggregation of the deposit is currently blocked by some extension mechanism. Used to filter out deposits that must not be processed by the canonical deposit logic.';
|
||||
COMMENT ON COLUMN deposits.extension_details_serial_id
|
||||
IS 'References extensions table, NULL if extensions are not used';
|
||||
COMMENT ON COLUMN deposits.policy_blocked
|
||||
IS 'True if the aggregation of the deposit is currently blocked by some policy extension mechanism. Used to filter out deposits that must not be processed by the canonical deposit logic.';
|
||||
COMMENT ON COLUMN deposits.policy_details_serial_id
|
||||
IS 'References policy extensions table, NULL if policy extensions are not used';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS deposits_default
|
||||
PARTITION OF deposits
|
||||
@ -607,7 +631,7 @@ CREATE OR REPLACE FUNCTION deposits_insert_trigger()
|
||||
DECLARE
|
||||
is_ready BOOLEAN;
|
||||
BEGIN
|
||||
is_ready = NOT (NEW.done OR NEW.extension_blocked);
|
||||
is_ready = NOT (NEW.done OR NEW.policy_blocked);
|
||||
|
||||
IF (is_ready)
|
||||
THEN
|
||||
@ -651,8 +675,8 @@ DECLARE
|
||||
DECLARE
|
||||
is_ready BOOLEAN;
|
||||
BEGIN
|
||||
was_ready = NOT (OLD.done OR OLD.extension_blocked);
|
||||
is_ready = NOT (NEW.done OR NEW.extension_blocked);
|
||||
was_ready = NOT (OLD.done OR OLD.policy_blocked);
|
||||
is_ready = NOT (NEW.done OR NEW.policy_blocked);
|
||||
IF (was_ready AND NOT is_ready)
|
||||
THEN
|
||||
DELETE FROM exchange.deposits_by_ready
|
||||
@ -706,7 +730,7 @@ CREATE OR REPLACE FUNCTION deposits_delete_trigger()
|
||||
DECLARE
|
||||
was_ready BOOLEAN;
|
||||
BEGIN
|
||||
was_ready = NOT (OLD.done OR OLD.extension_blocked);
|
||||
was_ready = NOT (OLD.done OR OLD.policy_blocked);
|
||||
|
||||
IF (was_ready)
|
||||
THEN
|
||||
|
@ -669,11 +669,11 @@ irbt_cb_table_deposits (struct PostgresClosure *pg,
|
||||
GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.wire_salt),
|
||||
GNUNET_PQ_query_param_auto_from_type (
|
||||
&td->details.deposits.wire_target_h_payto),
|
||||
GNUNET_PQ_query_param_bool (td->details.deposits.extension_blocked),
|
||||
0 == td->details.deposits.extension_details_serial_id
|
||||
GNUNET_PQ_query_param_bool (td->details.deposits.policy_blocked),
|
||||
0 == td->details.deposits.policy_details_serial_id
|
||||
? GNUNET_PQ_query_param_null ()
|
||||
: GNUNET_PQ_query_param_uint64 (
|
||||
&td->details.deposits.extension_details_serial_id),
|
||||
&td->details.deposits.policy_details_serial_id),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
|
||||
@ -905,9 +905,9 @@ irbt_cb_table_extensions (struct PostgresClosure *pg,
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_uint64 (&td->serial),
|
||||
GNUNET_PQ_query_param_string (td->details.extensions.name),
|
||||
NULL == td->details.extensions.config ?
|
||||
NULL == td->details.extensions.manifest ?
|
||||
GNUNET_PQ_query_param_null () :
|
||||
GNUNET_PQ_query_param_string (td->details.extensions.config),
|
||||
GNUNET_PQ_query_param_string (td->details.extensions.manifest),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
|
||||
@ -918,27 +918,27 @@ irbt_cb_table_extensions (struct PostgresClosure *pg,
|
||||
|
||||
|
||||
/**
|
||||
* Function called with extension_details records to insert into table.
|
||||
* Function called with policy_details records to insert into table.
|
||||
*
|
||||
* @param pg plugin context
|
||||
* @param td record to insert
|
||||
*/
|
||||
static enum GNUNET_DB_QueryStatus
|
||||
irbt_cb_table_extension_details (struct PostgresClosure *pg,
|
||||
irbt_cb_table_policy_details (struct PostgresClosure *pg,
|
||||
const struct TALER_EXCHANGEDB_TableData *td)
|
||||
{
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_uint64 (&td->serial),
|
||||
NULL ==
|
||||
td->details.extension_details.extension_options ?
|
||||
td->details.policy_details.policy_options ?
|
||||
GNUNET_PQ_query_param_null () :
|
||||
GNUNET_PQ_query_param_string (
|
||||
td->details.extension_details.extension_options),
|
||||
td->details.policy_details.policy_options),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
|
||||
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||
"insert_into_table_extension_details",
|
||||
"insert_into_table_policy_details",
|
||||
params);
|
||||
}
|
||||
|
||||
|
@ -895,7 +895,7 @@ lrbt_cb_table_deposits (void *cls,
|
||||
|
||||
for (unsigned int i = 0; i<num_results; i++)
|
||||
{
|
||||
bool no_extension;
|
||||
bool no_policy;
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_uint64 (
|
||||
"serial",
|
||||
@ -940,13 +940,13 @@ lrbt_cb_table_deposits (void *cls,
|
||||
"wire_target_h_payto",
|
||||
&td.details.deposits.wire_target_h_payto),
|
||||
GNUNET_PQ_result_spec_auto_from_type (
|
||||
"extension_blocked",
|
||||
&td.details.deposits.extension_blocked),
|
||||
"policy_blocked",
|
||||
&td.details.deposits.policy_blocked),
|
||||
GNUNET_PQ_result_spec_allow_null (
|
||||
GNUNET_PQ_result_spec_uint64 (
|
||||
"extension_details_serial_id",
|
||||
&td.details.deposits.extension_details_serial_id),
|
||||
&no_extension),
|
||||
"policy_details_serial_id",
|
||||
&td.details.deposits.policy_details_serial_id),
|
||||
&no_policy),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
@ -1400,8 +1400,8 @@ lrbt_cb_table_extensions (void *cls,
|
||||
GNUNET_PQ_result_spec_string ("name",
|
||||
&td.details.extensions.name),
|
||||
GNUNET_PQ_result_spec_allow_null (
|
||||
GNUNET_PQ_result_spec_string ("config",
|
||||
&td.details.extensions.config),
|
||||
GNUNET_PQ_result_spec_string ("manifest",
|
||||
&td.details.extensions.manifest),
|
||||
&no_config),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
@ -1423,33 +1423,95 @@ lrbt_cb_table_extensions (void *cls,
|
||||
|
||||
|
||||
/**
|
||||
* Function called with extension_details table entries.
|
||||
* Function called with policy_details table entries.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param result the postgres result
|
||||
* @param num_results the number of results in @a result
|
||||
*/
|
||||
static void
|
||||
lrbt_cb_table_extension_details (void *cls,
|
||||
lrbt_cb_table_policy_details (void *cls,
|
||||
PGresult *result,
|
||||
unsigned int num_results)
|
||||
{
|
||||
struct LookupRecordsByTableContext *ctx = cls;
|
||||
struct TALER_EXCHANGEDB_TableData td = {
|
||||
.table = TALER_EXCHANGEDB_RT_EXTENSION_DETAILS
|
||||
.table = TALER_EXCHANGEDB_RT_POLICY_DETAILS
|
||||
};
|
||||
|
||||
for (unsigned int i = 0; i<num_results; i++)
|
||||
{
|
||||
bool no_config = false;
|
||||
bool no_fulfilment = false;
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_uint64 ("extension_details_serial_id",
|
||||
GNUNET_PQ_result_spec_uint64 ("policy_details_serial_id",
|
||||
&td.serial),
|
||||
GNUNET_PQ_result_spec_auto_from_type ("serial_id",
|
||||
&td.details.policy_details.
|
||||
serial_id),
|
||||
GNUNET_PQ_result_spec_allow_null (
|
||||
GNUNET_PQ_result_spec_string ("policy_options",
|
||||
&td.details.policy_details.
|
||||
policy_options),
|
||||
&no_config),
|
||||
GNUNET_PQ_result_spec_allow_null (
|
||||
GNUNET_PQ_result_spec_uint64 ("fulfilment_serial_id",
|
||||
&td.details.policy_details.
|
||||
fulfilment_serial_id),
|
||||
&no_fulfilment),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_PQ_extract_result (result,
|
||||
rs,
|
||||
i))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
ctx->error = true;
|
||||
return;
|
||||
}
|
||||
ctx->cb (ctx->cb_cls,
|
||||
&td);
|
||||
GNUNET_PQ_cleanup_result (rs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function called with policy_fulfilments table entries.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param result the postgres result
|
||||
* @param num_results the number of results in @a result
|
||||
*/
|
||||
static void
|
||||
lrbt_cb_table_policy_fulfilments (void *cls,
|
||||
PGresult *result,
|
||||
unsigned int num_results)
|
||||
{
|
||||
struct LookupRecordsByTableContext *ctx = cls;
|
||||
struct TALER_EXCHANGEDB_TableData td = {
|
||||
.table = TALER_EXCHANGEDB_RT_POLICY_FULFILMENTS
|
||||
};
|
||||
|
||||
for (unsigned int i = 0; i<num_results; i++)
|
||||
{
|
||||
bool no_config = false;
|
||||
bool no_timestamp = false;
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
GNUNET_PQ_result_spec_uint64 ("policy_fulfilment_serial_id",
|
||||
&td.serial),
|
||||
GNUNET_PQ_result_spec_allow_null (
|
||||
GNUNET_PQ_result_spec_string ("extension_options",
|
||||
&td.details.extension_details.
|
||||
extension_options),
|
||||
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_end
|
||||
};
|
||||
|
||||
|
@ -2993,11 +2993,11 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
" LIMIT 1;",
|
||||
0),
|
||||
GNUNET_PQ_make_prepare (
|
||||
"select_serial_by_table_extension_details",
|
||||
"select_serial_by_table_policy_details",
|
||||
"SELECT"
|
||||
" extension_details_serial_id AS serial"
|
||||
" FROM extension_details"
|
||||
" ORDER BY extension_details_serial_id DESC"
|
||||
" policy_details_serial_id AS serial"
|
||||
" FROM policy_details"
|
||||
" ORDER BY policy_details_serial_id DESC"
|
||||
" LIMIT 1;",
|
||||
0),
|
||||
GNUNET_PQ_make_prepare (
|
||||
@ -3318,8 +3318,8 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
",wire_salt"
|
||||
",wire_target_h_payto"
|
||||
",done"
|
||||
",extension_blocked"
|
||||
",extension_details_serial_id"
|
||||
",policy_blocked"
|
||||
",policy_details_serial_id"
|
||||
" FROM deposits"
|
||||
" WHERE deposit_serial_id > $1"
|
||||
" ORDER BY deposit_serial_id ASC;",
|
||||
@ -3821,8 +3821,8 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
",coin_sig"
|
||||
",wire_salt"
|
||||
",wire_target_h_payto"
|
||||
",extension_blocked"
|
||||
",extension_details_serial_id"
|
||||
",policy_blocked"
|
||||
",policy_details_serial_id"
|
||||
") VALUES "
|
||||
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
|
||||
" $11, $12, $13, $14, $15, $16, $17);",
|
||||
@ -3927,14 +3927,24 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
"($1, $2, $3);",
|
||||
3),
|
||||
GNUNET_PQ_make_prepare (
|
||||
"insert_into_table_extension_details",
|
||||
"INSERT INTO extension_details"
|
||||
"(extension_details_serial_id"
|
||||
",extension_options"
|
||||
"insert_into_table_policy_details",
|
||||
"INSERT INTO policy_details"
|
||||
"(policy_details_serial_id"
|
||||
",serial_id"
|
||||
",policy_options"
|
||||
",fulfilment_serial_id"
|
||||
") VALUES "
|
||||
"($1, $2);",
|
||||
2),
|
||||
|
||||
"($1, $2, $3, $4);",
|
||||
4),
|
||||
GNUNET_PQ_make_prepare (
|
||||
"insert_into_table_policy_fulfilments",
|
||||
"INSERT INTO policy_fulfilments"
|
||||
"(policy_fulfilments_serial_id"
|
||||
",fulfilment_timestamp"
|
||||
",fulfilment_proof"
|
||||
") VALUES "
|
||||
"($1, $2, $3);",
|
||||
3),
|
||||
GNUNET_PQ_make_prepare (
|
||||
"insert_into_table_purse_requests",
|
||||
"INSERT INTO purse_requests"
|
||||
@ -6230,7 +6240,7 @@ compute_shard (const struct TALER_MerchantPublicKeyP *merchant_pub)
|
||||
* @param deposit deposit operation details
|
||||
* @param known_coin_id row of the coin in the known_coins table
|
||||
* @param h_payto hash of the merchant's bank account details
|
||||
* @param extension_blocked true if an extension is blocking the wire transfer
|
||||
* @param policy_blocked true if an extension is blocking the wire transfer
|
||||
* @param[in,out] exchange_timestamp time to use for the deposit (possibly updated)
|
||||
* @param[out] balance_ok set to true if the balance was sufficient
|
||||
* @param[out] in_conflict set to true if the deposit conflicted
|
||||
@ -6242,7 +6252,7 @@ postgres_do_deposit (
|
||||
const struct TALER_EXCHANGEDB_Deposit *deposit,
|
||||
uint64_t known_coin_id,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
bool extension_blocked,
|
||||
bool policy_blocked,
|
||||
struct GNUNET_TIME_Timestamp *exchange_timestamp,
|
||||
bool *balance_ok,
|
||||
bool *in_conflict)
|
||||
@ -6264,7 +6274,7 @@ postgres_do_deposit (
|
||||
GNUNET_PQ_query_param_auto_from_type (&deposit->coin.coin_pub),
|
||||
GNUNET_PQ_query_param_auto_from_type (&deposit->csig),
|
||||
GNUNET_PQ_query_param_uint64 (&deposit_shard),
|
||||
GNUNET_PQ_query_param_bool (extension_blocked),
|
||||
GNUNET_PQ_query_param_bool (policy_blocked),
|
||||
(NULL == deposit->policy_details)
|
||||
? GNUNET_PQ_query_param_null ()
|
||||
: TALER_PQ_query_param_json (deposit->policy_details),
|
||||
@ -14225,8 +14235,8 @@ postgres_lookup_serial_by_table (void *cls,
|
||||
case TALER_EXCHANGEDB_RT_EXTENSIONS:
|
||||
statement = "select_serial_by_table_extensions";
|
||||
break;
|
||||
case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
|
||||
statement = "select_serial_by_table_extension_details";
|
||||
case TALER_EXCHANGEDB_RT_POLICY_DETAILS:
|
||||
statement = "select_serial_by_table_policy_details";
|
||||
break;
|
||||
case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
|
||||
statement = "select_serial_by_table_purse_requests";
|
||||
@ -14437,9 +14447,13 @@ postgres_lookup_records_by_table (void *cls,
|
||||
statement = "select_above_serial_by_table_extensions";
|
||||
rh = &lrbt_cb_table_extensions;
|
||||
break;
|
||||
case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
|
||||
statement = "select_above_serial_by_table_extension_details";
|
||||
rh = &lrbt_cb_table_extension_details;
|
||||
case TALER_EXCHANGEDB_RT_POLICY_DETAILS:
|
||||
statement = "select_above_serial_by_table_policy_details";
|
||||
rh = &lrbt_cb_table_policy_details;
|
||||
break;
|
||||
case TALER_EXCHANGEDB_RT_POLICY_FULFILMENTS:
|
||||
statement = "select_above_serial_by_table_policy_fulfilments";
|
||||
rh = &lrbt_cb_table_policy_fulfilments;
|
||||
break;
|
||||
case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
|
||||
statement = "select_above_serial_by_table_purse_requests";
|
||||
@ -14620,8 +14634,8 @@ postgres_insert_records_by_table (void *cls,
|
||||
case TALER_EXCHANGEDB_RT_EXTENSIONS:
|
||||
rh = &irbt_cb_table_extensions;
|
||||
break;
|
||||
case TALER_EXCHANGEDB_RT_EXTENSION_DETAILS:
|
||||
rh = &irbt_cb_table_extension_details;
|
||||
case TALER_EXCHANGEDB_RT_POLICY_DETAILS:
|
||||
rh = &irbt_cb_table_policy_details;
|
||||
break;
|
||||
case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
|
||||
rh = &irbt_cb_table_purse_requests;
|
||||
|
@ -510,8 +510,8 @@ CREATE OR REPLACE FUNCTION exchange_do_deposit(
|
||||
IN in_coin_pub BYTEA,
|
||||
IN in_coin_sig BYTEA,
|
||||
IN in_shard INT8,
|
||||
IN in_extension_blocked BOOLEAN,
|
||||
IN in_extension_details VARCHAR,
|
||||
IN in_policy_blocked BOOLEAN,
|
||||
IN in_policy_details VARCHAR,
|
||||
OUT out_exchange_timestamp INT8,
|
||||
OUT out_balance_ok BOOLEAN,
|
||||
OUT out_conflict BOOLEAN)
|
||||
@ -522,18 +522,18 @@ DECLARE
|
||||
DECLARE
|
||||
xdi INT8; -- eXstension details serial id
|
||||
BEGIN
|
||||
-- Shards: INSERT extension_details (by extension_details_serial_id)
|
||||
-- Shards: INSERT policy_details (by policy_details_serial_id)
|
||||
-- INSERT wire_targets (by h_payto), on CONFLICT DO NOTHING;
|
||||
-- INSERT deposits (by coin_pub, shard), ON CONFLICT DO NOTHING;
|
||||
-- UPDATE known_coins (by coin_pub)
|
||||
|
||||
IF NOT NULL in_extension_details
|
||||
IF NOT NULL in_policy_details
|
||||
THEN
|
||||
INSERT INTO exchange.extension_details
|
||||
(extension_options)
|
||||
INSERT INTO exchange.policy_details
|
||||
(policy_options)
|
||||
VALUES
|
||||
(in_extension_details)
|
||||
RETURNING extension_details_serial_id INTO xdi;
|
||||
(in_policy_details)
|
||||
RETURNING policy_details_serial_id INTO xdi;
|
||||
ELSE
|
||||
xdi=NULL;
|
||||
END IF;
|
||||
@ -572,8 +572,8 @@ INSERT INTO exchange.deposits
|
||||
,coin_sig
|
||||
,wire_salt
|
||||
,wire_target_h_payto
|
||||
,extension_blocked
|
||||
,extension_details_serial_id
|
||||
,policy_blocked
|
||||
,policy_details_serial_id
|
||||
)
|
||||
VALUES
|
||||
(in_shard
|
||||
@ -590,7 +590,7 @@ INSERT INTO exchange.deposits
|
||||
,in_coin_sig
|
||||
,in_wire_salt
|
||||
,in_h_payto
|
||||
,in_extension_blocked
|
||||
,in_policy_blocked
|
||||
,xdi)
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
|
@ -221,7 +221,8 @@ enum TALER_EXCHANGEDB_ReplicatedTable
|
||||
TALER_EXCHANGEDB_RT_RECOUP,
|
||||
TALER_EXCHANGEDB_RT_RECOUP_REFRESH,
|
||||
TALER_EXCHANGEDB_RT_EXTENSIONS,
|
||||
TALER_EXCHANGEDB_RT_EXTENSION_DETAILS,
|
||||
TALER_EXCHANGEDB_RT_POLICY_DETAILS,
|
||||
TALER_EXCHANGEDB_RT_POLICY_FULFILMENTS,
|
||||
TALER_EXCHANGEDB_RT_PURSE_REQUESTS,
|
||||
TALER_EXCHANGEDB_RT_PURSE_REFUNDS,
|
||||
TALER_EXCHANGEDB_RT_PURSE_MERGES,
|
||||
@ -448,8 +449,8 @@ struct TALER_EXCHANGEDB_TableData
|
||||
struct TALER_CoinSpendSignatureP coin_sig;
|
||||
struct TALER_WireSaltP wire_salt;
|
||||
struct TALER_PaytoHashP wire_target_h_payto;
|
||||
bool extension_blocked;
|
||||
uint64_t extension_details_serial_id;
|
||||
bool policy_blocked;
|
||||
uint64_t policy_details_serial_id;
|
||||
} deposits;
|
||||
|
||||
struct
|
||||
@ -521,13 +522,22 @@ struct TALER_EXCHANGEDB_TableData
|
||||
struct
|
||||
{
|
||||
char *name;
|
||||
char *config;
|
||||
char *manifest;
|
||||
} extensions;
|
||||
|
||||
struct
|
||||
{
|
||||
char *extension_options;
|
||||
} extension_details;
|
||||
char *policy_options;
|
||||
struct GNUNET_HashCode serial_id;
|
||||
struct GNUNET_TIME_Timestamp deadline;
|
||||
uint64_t fulfilment_serial_id;
|
||||
} policy_details;
|
||||
|
||||
struct
|
||||
{
|
||||
char *fulfilment_proof;
|
||||
struct GNUNET_TIME_Timestamp fulfilment_timestamp;
|
||||
} policy_fulfilments;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -3313,7 +3323,7 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
* @param deposit deposit operation details
|
||||
* @param known_coin_id row of the coin in the known_coins table
|
||||
* @param h_payto hash of the merchant's payto URI
|
||||
* @param extension_blocked true if an extension is blocking the wire transfer
|
||||
* @param policy_blocked true if an policy extension is blocking the wire transfer
|
||||
* @param[in,out] exchange_timestamp time to use for the deposit (possibly updated)
|
||||
* @param[out] balance_ok set to true if the balance was sufficient
|
||||
* @param[out] in_conflict set to true if the deposit conflicted
|
||||
@ -3325,7 +3335,7 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
const struct TALER_EXCHANGEDB_Deposit *deposit,
|
||||
uint64_t known_coin_id,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
bool extension_blocked,
|
||||
bool policy_blocked,
|
||||
struct GNUNET_TIME_Timestamp *exchange_timestamp,
|
||||
bool *balance_ok,
|
||||
bool *in_conflict);
|
||||
@ -5246,7 +5256,7 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*set_extension_manifest)(void *cls,
|
||||
const char *extension_name,
|
||||
const char *config);
|
||||
const char *manifest);
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user