summaryrefslogtreecommitdiff
path: root/src/backenddb/plugin_merchantdb_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-07-10 10:37:25 +0200
committerChristian Grothoff <christian@grothoff.org>2023-07-10 10:37:25 +0200
commit3ebb5281bc62ca6231f6131e0601471d9ef03b8b (patch)
tree28037cedcb8383e5b32c8d11ae527612efb0609c /src/backenddb/plugin_merchantdb_postgres.c
parentc4b27ca9b9a5ef4291257e4a8b8f4bac56720b89 (diff)
downloadmerchant-3ebb5281bc62ca6231f6131e0601471d9ef03b8b.tar.gz
merchant-3ebb5281bc62ca6231f6131e0601471d9ef03b8b.tar.bz2
merchant-3ebb5281bc62ca6231f6131e0601471d9ef03b8b.zip
tip -> reward
Diffstat (limited to 'src/backenddb/plugin_merchantdb_postgres.c')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c528
1 files changed, 264 insertions, 264 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 35d6f111..cac8c982 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -152,7 +152,7 @@ postgres_create_tables (void *cls)
* @param es specification of the event to listen for
* @param timeout how long to wait for the event
* @param cb function to call when the event happens, possibly
- * multiple times (until cancel is invoked)
+ * mulrewardle times (until cancel is invoked)
* @param cb_cls closure for @a cb
* @return handle useful to cancel the listener
*/
@@ -1053,7 +1053,7 @@ process_deposits_for_refund_cb (void *cls,
* Function called when some backoffice staff decides to award or
* increase the refund on an existing contract. This function
* MUST be called from within a transaction scope setup by the
- * caller as it executes multiple SQL statements.
+ * caller as it executes mulrewardle SQL statements.
*
* @param cls closure
* @param instance_id instance identifier
@@ -2295,10 +2295,10 @@ postgres_store_wire_fee_by_exchange (
/**
- * Add @a credit to a reserve to be used for tipping. Note that
+ * Add @a credit to a reserve to be used for rewardping. Note that
* this function does not actually perform any wire transfers to
* credit the reserve, it merely tells the merchant backend that
- * a reserve now exists. This has to happen before tips can be
+ * a reserve now exists. This has to happen before rewards can be
* authorized.
*
* @param cls closure, typically a connection to the db
@@ -2396,7 +2396,7 @@ RETRY:
/**
* Confirms @a credit as the amount the exchange claims to have received and
- * thus really 'activates' the reserve. This has to happen before tips can
+ * thus really 'activates' the reserve. This has to happen before rewards can
* be authorized.
*
* @param cls closure, typically a connection to the db
@@ -2545,9 +2545,9 @@ postgres_lookup_pending_reserves (void *cls,
/**
- * Closure for #lookup_reserve_tips_cb().
+ * Closure for #lookup_reserve_rewards_cb().
*/
-struct LookupTipsContext
+struct LookupRewardsContext
{
/**
* Postgres context.
@@ -2555,14 +2555,14 @@ struct LookupTipsContext
struct PostgresClosure *pg;
/**
- * Array with information about tips generated from this reserve.
+ * Array with information about rewards generated from this reserve.
*/
- struct TALER_MERCHANTDB_TipDetails *tips;
+ struct TALER_MERCHANTDB_RewardDetails *rewards;
/**
- * Length of the @e tips array.
+ * Length of the @e rewards array.
*/
- unsigned int tips_length;
+ unsigned int rewards_length;
/**
* Set in case of errors.
@@ -2575,29 +2575,29 @@ struct LookupTipsContext
* Function to be called with the results of a SELECT statement
* that has returned @a num_results results about accounts.
*
- * @param[in,out] cls of type `struct LookupTipsContext *`
+ * @param[in,out] cls of type `struct LookupRewardsContext *`
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
-lookup_reserve_tips_cb (void *cls,
+lookup_reserve_rewards_cb (void *cls,
PGresult *result,
unsigned int num_results)
{
- struct LookupTipsContext *ltc = cls;
+ struct LookupRewardsContext *ltc = cls;
struct PostgresClosure *pg = ltc->pg;
- GNUNET_array_grow (ltc->tips,
- ltc->tips_length,
+ GNUNET_array_grow (ltc->rewards,
+ ltc->rewards_length,
num_results);
for (unsigned int i = 0; i < num_results; i++)
{
- struct TALER_MERCHANTDB_TipDetails *td = &ltc->tips[i];
+ struct TALER_MERCHANTDB_RewardDetails *td = &ltc->rewards[i];
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_string ("justification",
&td->reason),
- GNUNET_PQ_result_spec_auto_from_type ("tip_id",
- &td->tip_id),
+ GNUNET_PQ_result_spec_auto_from_type ("reward_id",
+ &td->reward_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
&td->total_amount),
GNUNET_PQ_result_spec_end
@@ -2622,7 +2622,7 @@ lookup_reserve_tips_cb (void *cls,
* @param cls closure
* @param instance_id instance to lookup payments for
* @param reserve_pub public key of the reserve to inspect
- * @param fetch_tips if true, also return information about tips
+ * @param fetch_rewards if true, also return information about rewards
* @param cb function to call with reserve summary data
* @param cb_cls closure for @a cb
* @return transaction status
@@ -2631,12 +2631,12 @@ static enum GNUNET_DB_QueryStatus
postgres_lookup_reserve (void *cls,
const char *instance_id,
const struct TALER_ReservePublicKeyP *reserve_pub,
- bool fetch_tips,
+ bool fetch_rewards,
TALER_MERCHANTDB_ReserveDetailsCallback cb,
void *cb_cls)
{
struct PostgresClosure *pg = cls;
- struct LookupTipsContext ltc = {
+ struct LookupRewardsContext ltc = {
.pg = pg,
.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
};
@@ -2663,9 +2663,9 @@ postgres_lookup_reserve (void *cls,
&merchant_initial_balance),
TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_initial_balance",
&exchange_initial_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("tips_picked_up",
+ TALER_PQ_RESULT_SPEC_AMOUNT ("rewards_picked_up",
&pickup_amount),
- TALER_PQ_RESULT_SPEC_AMOUNT ("tips_committed",
+ TALER_PQ_RESULT_SPEC_AMOUNT ("rewards_committed",
&committed_amount),
GNUNET_PQ_result_spec_auto_from_type ("master_pub",
&master_pub),
@@ -2686,7 +2686,7 @@ postgres_lookup_reserve (void *cls,
rs);
if (qs < 0)
return qs;
- if (! fetch_tips)
+ if (! fetch_rewards)
{
cb (cb_cls,
creation_time,
@@ -2705,9 +2705,9 @@ postgres_lookup_reserve (void *cls,
}
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "lookup_reserve_tips",
+ "lookup_reserve_rewards",
params,
- &lookup_reserve_tips_cb,
+ &lookup_reserve_rewards_cb,
&ltc);
if (qs < 0)
return qs;
@@ -2723,13 +2723,13 @@ postgres_lookup_reserve (void *cls,
active,
&master_pub,
exchange_url,
- ltc.tips_length,
- ltc.tips);
+ ltc.rewards_length,
+ ltc.rewards);
}
- for (unsigned int i = 0; i<ltc.tips_length; i++)
- GNUNET_free (ltc.tips[i].reason);
- GNUNET_array_grow (ltc.tips,
- ltc.tips_length,
+ for (unsigned int i = 0; i<ltc.rewards_length; i++)
+ GNUNET_free (ltc.rewards[i].reason);
+ GNUNET_array_grow (ltc.rewards,
+ ltc.rewards_length,
0);
GNUNET_PQ_cleanup_result (rs);
return ltc.qs;
@@ -2765,7 +2765,7 @@ postgres_delete_reserve (void *cls,
/**
- * Purge all of the information about a reserve, including tips.
+ * Purge all of the information about a reserve, including rewards.
*
* @param cls closure, typically a connection to the db
* @param instance_id which instance is the reserve tied to
@@ -2793,9 +2793,9 @@ postgres_purge_reserve (void *cls,
/**
- * Closure for #lookup_reserve_for_tip_cb().
+ * Closure for #lookup_reserve_for_reward_cb().
*/
-struct LookupReserveForTipContext
+struct LookupReserveForRewardContext
{
/**
* Postgres context.
@@ -2832,7 +2832,7 @@ struct LookupReserveForTipContext
/**
* How long must a reserve be at least still valid before we use
- * it for a tip?
+ * it for a reward?
*/
#define MIN_EXPIRATION GNUNET_TIME_UNIT_HOURS
@@ -2841,16 +2841,16 @@ struct LookupReserveForTipContext
* Function to be called with the results of a SELECT statement
* that has returned @a num_results results about accounts.
*
- * @param[in,out] cls of type `struct LookupReserveForTipContext *`
+ * @param[in,out] cls of type `struct LookupReserveForRewardContext *`
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
-lookup_reserve_for_tip_cb (void *cls,
+lookup_reserve_for_reward_cb (void *cls,
PGresult *result,
unsigned int num_results)
{
- struct LookupReserveForTipContext *lac = cls;
+ struct LookupReserveForRewardContext *lac = cls;
struct PostgresClosure *pg = lac->pg;
for (unsigned int i = 0; i < num_results; i++)
@@ -2865,7 +2865,7 @@ lookup_reserve_for_tip_cb (void *cls,
&reserve_pub),
TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_initial_balance",
&initial_balance),
- TALER_PQ_RESULT_SPEC_AMOUNT ("tips_committed",
+ TALER_PQ_RESULT_SPEC_AMOUNT ("rewards_committed",
&committed_amount),
GNUNET_PQ_result_spec_timestamp ("expiration",
&expiration),
@@ -2896,7 +2896,7 @@ lookup_reserve_for_tip_cb (void *cls,
/* insufficient balance */
if (lac->ok)
continue; /* got another reserve */
- lac->ec = TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS;
+ lac->ec = TALER_EC_MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_INSUFFICIENT_FUNDS;
continue;
}
if ( (! GNUNET_TIME_absolute_is_never (lac->expiration.abs_time)) &&
@@ -2911,7 +2911,7 @@ lookup_reserve_for_tip_cb (void *cls,
/* reserve expired */
if (lac->ok)
continue; /* got another reserve */
- lac->ec = TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_EXPIRED;
+ lac->ec = TALER_EC_MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_EXPIRED;
continue;
}
lac->ok = true;
@@ -2923,22 +2923,22 @@ lookup_reserve_for_tip_cb (void *cls,
/**
- * Authorize a tip over @a amount from reserve @a reserve_pub. Remember
- * the authorization under @a tip_id for later, together with the
+ * Authorize a reward over @a amount from reserve @a reserve_pub. Remember
+ * the authorization under @a reward_id for later, together with the
* @a justification.
*
* @param cls closure, typically a connection to the db
- * @param instance_id which instance should generate the tip
+ * @param instance_id which instance should generate the reward
* @param reserve_pub which reserve is debited, NULL to pick one in the DB
- * @param amount how high is the tip (with fees)
- * @param justification why was the tip approved
- * @param next_url where to send the URL post tip pickup
- * @param[out] tip_id set to the unique ID for the tip
- * @param[out] expiration set to when the tip expires
+ * @param amount how high is the reward (with fees)
+ * @param justification why was the reward approved
+ * @param next_url where to send the URL post reward pickup
+ * @param[out] reward_id set to the unique ID for the reward
+ * @param[out] expiration set to when the reward expires
* @return transaction status,
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_EXPIRED if the reserve is known but has expired
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND if the reserve is not known
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS if the reserve has insufficient funds left
+ * #TALER_EC_MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_EXPIRED if the reserve is known but has expired
+ * #TALER_EC_MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_NOT_FOUND if the reserve is not known
+ * #TALER_EC_MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_INSUFFICIENT_FUNDS if the reserve has insufficient funds left
* #TALER_EC_GENERIC_DB_START_FAILED on hard DB errors
* #TALER_EC_GENERIC_DB_FETCH_FAILED on hard DB errors
* #TALER_EC_GENERIC_DB_STORE_FAILED on hard DB errors
@@ -2947,22 +2947,22 @@ lookup_reserve_for_tip_cb (void *cls,
* #TALER_EC_NONE upon success
*/
static enum TALER_ErrorCode
-postgres_authorize_tip (void *cls,
+postgres_authorize_reward (void *cls,
const char *instance_id,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
const char *justification,
const char *next_url,
- struct TALER_TipIdentifierP *tip_id,
+ struct TALER_RewardIdentifierP *reward_id,
struct GNUNET_TIME_Timestamp *expiration)
{
struct PostgresClosure *pg = cls;
unsigned int retries = 0;
enum GNUNET_DB_QueryStatus qs;
- struct TALER_Amount tips_committed;
+ struct TALER_Amount rewards_committed;
struct TALER_Amount exchange_initial_balance;
const struct TALER_ReservePublicKeyP *reserve_pubp;
- struct LookupReserveForTipContext lac = {
+ struct LookupReserveForRewardContext lac = {
.pg = pg,
.required_amount = *amount,
.expiration = GNUNET_TIME_UNIT_FOREVER_TS
@@ -2979,7 +2979,7 @@ RETRY:
}
if (GNUNET_OK !=
postgres_start (pg,
- "authorize tip"))
+ "authorize reward"))
{
GNUNET_break (0);
return TALER_EC_GENERIC_DB_START_FAILED;
@@ -2992,9 +2992,9 @@ RETRY:
};
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "lookup_reserve_for_tip",
+ "lookup_reserve_for_reward",
params,
- &lookup_reserve_for_tip_cb,
+ &lookup_reserve_for_reward_cb,
&lac);
switch (qs)
{
@@ -3007,7 +3007,7 @@ RETRY:
return TALER_EC_GENERIC_DB_FETCH_FAILED;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
postgres_rollback (pg);
- return TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND;
+ return TALER_EC_MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_NOT_FOUND;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
default:
break;
@@ -3015,7 +3015,7 @@ RETRY:
if (TALER_EC_NONE != lac.ec)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Enabling tip reserved failed with status %d\n",
+ "Enabling reward reserved failed with status %d\n",
lac.ec);
postgres_rollback (pg);
return lac.ec;
@@ -3033,8 +3033,8 @@ RETRY:
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_timestamp ("expiration",
expiration),
- TALER_PQ_RESULT_SPEC_AMOUNT ("tips_committed",
- &tips_committed),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("rewards_committed",
+ &rewards_committed),
TALER_PQ_RESULT_SPEC_AMOUNT ("exchange_initial_balance",
&exchange_initial_balance),
GNUNET_PQ_result_spec_end
@@ -3058,7 +3058,7 @@ RETRY:
if (0 == qs)
{
postgres_rollback (pg);
- return TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND;
+ return TALER_EC_MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_RESERVE_NOT_FOUND;
}
}
{
@@ -3067,7 +3067,7 @@ RETRY:
if (0 >
TALER_amount_subtract (&remaining,
&exchange_initial_balance,
- &tips_committed))
+ &rewards_committed))
{
GNUNET_break (0);
postgres_rollback (pg);
@@ -3078,23 +3078,23 @@ RETRY:
amount))
{
postgres_rollback (pg);
- return TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS;
+ return TALER_EC_MERCHANT_PRIVATE_POST_REWARD_AUTHORIZE_INSUFFICIENT_FUNDS;
}
}
GNUNET_assert (0 <=
- TALER_amount_add (&tips_committed,
- &tips_committed,
+ TALER_amount_add (&rewards_committed,
+ &rewards_committed,
amount));
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
GNUNET_PQ_query_param_auto_from_type (reserve_pubp),
- TALER_PQ_query_param_amount (&tips_committed),
+ TALER_PQ_query_param_amount (&rewards_committed),
GNUNET_PQ_query_param_end
};
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "update_reserve_tips_committed",
+ "update_reserve_rewards_committed",
params);
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
{
@@ -3109,13 +3109,13 @@ RETRY:
}
}
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
- tip_id,
- sizeof (*tip_id));
+ reward_id,
+ sizeof (*reward_id));
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
GNUNET_PQ_query_param_auto_from_type (reserve_pubp),
- GNUNET_PQ_query_param_auto_from_type (tip_id),
+ GNUNET_PQ_query_param_auto_from_type (reward_id),
GNUNET_PQ_query_param_string (justification),
GNUNET_PQ_query_param_string (next_url),
GNUNET_PQ_query_param_timestamp (expiration),
@@ -3124,7 +3124,7 @@ RETRY:
};
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_tip",
+ "insert_reward",
params);
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
{
@@ -3221,11 +3221,11 @@ lookup_signatures_cb (void *cls,
* Lookup pickup details for pickup @a pickup_id.
*
* @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
+ * @param instance_id which instance should we lookup reward details for
+ * @param reward_id which reward should we lookup details on
* @param pickup_id which pickup should we lookup details on
- * @param[out] exchange_url which exchange is the tip withdrawn from
- * @param[out] reserve_priv private key the tip is withdrawn from (set if still available!)
+ * @param[out] exchange_url which exchange is the reward withdrawn from
+ * @param[out] reserve_priv private key the reward is withdrawn from (set if still available!)
* @param sigs_length length of the @a sigs array
* @param[out] sigs set to the (blind) signatures we have for this @a pickup_id,
* those that are unavailable are left at NULL
@@ -3234,7 +3234,7 @@ lookup_signatures_cb (void *cls,
static enum GNUNET_DB_QueryStatus
postgres_lookup_pickup (void *cls,
const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
+ const struct TALER_RewardIdentifierP *reward_id,
const struct TALER_PickupIdentifierP *pickup_id,
char **exchange_url,
struct TALER_ReservePrivateKeyP *reserve_priv,
@@ -3247,7 +3247,7 @@ postgres_lookup_pickup (void *cls,
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_auto_from_type (tip_id),
+ GNUNET_PQ_query_param_auto_from_type (reward_id),
GNUNET_PQ_query_param_auto_from_type (pickup_id),
GNUNET_PQ_query_param_end
};
@@ -3289,23 +3289,23 @@ postgres_lookup_pickup (void *cls,
/**
- * Lookup tip details for tip @a tip_id.
+ * Lookup reward details for reward @a reward_id.
*
* @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
- * @param[out] total_authorized amount how high is the tip (with fees)
- * @param[out] total_picked_up how much of the tip was so far picked up (with fees)
- * @param[out] expiration set to when the tip expires
+ * @param instance_id which instance should we lookup reward details for
+ * @param reward_id which reward should we lookup details on
+ * @param[out] total_authorized amount how high is the reward (with fees)
+ * @param[out] total_picked_up how much of the reward was so far picked up (with fees)
+ * @param[out] expiration set to when the reward expires
* @param[out] exchange_url set to the exchange URL where the reserve is
- * @param[out] next_url set to the URL where the wallet should navigate after getting the tip
+ * @param[out] next_url set to the URL where the wallet should navigate after getting the reward
* @param[out] reserve_priv set to private key of reserve to be debited
* @return transaction status
*/
static enum GNUNET_DB_QueryStatus
-postgres_lookup_tip (void *cls,
+postgres_lookup_reward (void *cls,
const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
+ const struct TALER_RewardIdentifierP *reward_id,
struct TALER_Amount *total_authorized,
struct TALER_Amount *total_picked_up,
struct GNUNET_TIME_Timestamp *expiration,
@@ -3316,7 +3316,7 @@ postgres_lookup_tip (void *cls,
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_auto_from_type (tip_id),
+ GNUNET_PQ_query_param_auto_from_type (reward_id),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -3336,16 +3336,16 @@ postgres_lookup_tip (void *cls,
};
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_tip",
+ "lookup_reward",
params,
rs);
}
/**
- * Context used for postgres_lookup_tips().
+ * Context used for postgres_lookup_rewards().
*/
-struct LookupMerchantTipsContext
+struct LookupMerchantRewardsContext
{
/**
* Postgres context.
@@ -3355,7 +3355,7 @@ struct LookupMerchantTipsContext
/**
* Function to call with the results.
*/
- TALER_MERCHANTDB_TipsCallback cb;
+ TALER_MERCHANTDB_RewardsCallback cb;
/**
* Closure for @a cb.
@@ -3371,32 +3371,32 @@ struct LookupMerchantTipsContext
/**
* Function to be called with the results of a SELECT statement
- * that has returned @a num_results results about tips.
+ * that has returned @a num_results results about rewards.
*
- * @param[in,out] cls of type `struct LookupTipsContext *`
+ * @param[in,out] cls of type `struct LookupRewardsContext *`
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
-lookup_tips_cb (void *cls,
+lookup_rewards_cb (void *cls,
PGresult *result,
unsigned int num_results)
{
- struct LookupMerchantTipsContext *plc = cls;
+ struct LookupMerchantRewardsContext *plc = cls;
struct PostgresClosure *pg = plc->pg;
for (unsigned int i = 0; i < num_results; i++)
{
uint64_t row_id;
- struct TALER_TipIdentifierP tip_id;
- struct TALER_Amount tip_amount;
+ struct TALER_RewardIdentifierP reward_id;
+ struct TALER_Amount reward_amount;
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("tip_serial",
+ GNUNET_PQ_result_spec_uint64 ("reward_serial",
&row_id),
- GNUNET_PQ_result_spec_auto_from_type ("tip_id",
- &tip_id),
+ GNUNET_PQ_result_spec_auto_from_type ("reward_id",
+ &reward_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
- &tip_amount),
+ &reward_amount),
GNUNET_PQ_result_spec_end
};
@@ -3411,37 +3411,37 @@ lookup_tips_cb (void *cls,
}
plc->cb (plc->cb_cls,
row_id,
- tip_id,
- tip_amount);
+ reward_id,
+ reward_amount);
GNUNET_PQ_cleanup_result (rs);
}
}
/**
- * Lookup tips
+ * Lookup rewards
*
* @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tips for
- * @param expired should we include expired tips?
+ * @param instance_id which instance should we lookup rewards for
+ * @param expired should we include expired rewards?
* @param limit maximum number of results to return, positive for
* ascending row id, negative for descending
* @param offset row id to start returning results from
- * @param cb function to call with tip data
+ * @param cb function to call with reward data
* @param cb_cls closure for @a cb
* @return transaction status
*/
static enum GNUNET_DB_QueryStatus
-postgres_lookup_tips (void *cls,
+postgres_lookup_rewards (void *cls,
const char *instance_id,
enum TALER_EXCHANGE_YesNoAll expired,
int64_t limit,
uint64_t offset,
- TALER_MERCHANTDB_TipsCallback cb,
+ TALER_MERCHANTDB_RewardsCallback cb,
void *cb_cls)
{
struct PostgresClosure *pg = cls;
- struct LookupMerchantTipsContext plc = {
+ struct LookupMerchantRewardsContext plc = {
.pg = pg,
.cb = cb,
.cb_cls = cb_cls
@@ -3463,13 +3463,13 @@ postgres_lookup_tips (void *cls,
bexpired = (TALER_EXCHANGE_YNA_YES == expired);
GNUNET_snprintf (stmt,
sizeof (stmt),
- "lookup_tips_%s%s",
+ "lookup_rewards_%s%s",
(limit > 0) ? "inc" : "dec",
(TALER_EXCHANGE_YNA_ALL == expired) ? "" : "_expired");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
stmt,
params,
- &lookup_tips_cb,
+ &lookup_rewards_cb,
&plc);
if (0 != plc.qs)
return plc.qs;
@@ -3480,7 +3480,7 @@ postgres_lookup_tips (void *cls,
/**
* Closure for #lookup_pickup_details_cb().
*/
-struct LookupTipDetailsContext
+struct LookupRewardDetailsContext
{
/**
* Length of the @e sigs array
@@ -3509,7 +3509,7 @@ struct LookupTipDetailsContext
* Function to be called with the results of a SELECT statement
* that has returned @a num_results results about pickups.
*
- * @param[in,out] cls of type `struct LookupTipDetailsContext *`
+ * @param[in,out] cls of type `struct LookupRewardDetailsContext *`
* @param result the postgres result
* @param num_results the number of results in @a result
*/
@@ -3518,7 +3518,7 @@ lookup_pickup_details_cb (void *cls,
PGresult *result,
unsigned int num_results)
{
- struct LookupTipDetailsContext *ltdc = cls;
+ struct LookupRewardDetailsContext *ltdc = cls;
struct PostgresClosure *pg = ltdc->pg;
*ltdc->pickups_length = num_results;
@@ -3557,25 +3557,25 @@ lookup_pickup_details_cb (void *cls,
/**
- * Lookup tip details for tip @a tip_id.
+ * Lookup reward details for reward @a reward_id.
*
* @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
+ * @param instance_id which instance should we lookup reward details for
+ * @param reward_id which reward should we lookup details on
* @param fpu should we fetch details about individual pickups
- * @param[out] total_authorized amount how high is the tip (with fees)
- * @param[out] total_picked_up how much of the tip was so far picked up (with fees)
- * @param[out] justification why was the tip approved
- * @param[out] expiration set to when the tip expires
+ * @param[out] total_authorized amount how high is the reward (with fees)
+ * @param[out] total_picked_up how much of the reward was so far picked up (with fees)
+ * @param[out] justification why was the reward approved
+ * @param[out] expiration set to when the reward expires
* @param[out] reserve_pub set to which reserve is debited
* @param[out] pickups_length set to the length of @e pickups
* @param[out] pickups if @a fpu is true, set to details about the pickup operations
* @return transaction status,
*/
static enum GNUNET_DB_QueryStatus
-postgres_lookup_tip_details (void *cls,
+postgres_lookup_reward_details (void *cls,
const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
+ const struct TALER_RewardIdentifierP *reward_id,
bool fpu,
struct TALER_Amount *total_authorized,
struct TALER_Amount *total_picked_up,
@@ -3586,17 +3586,17 @@ postgres_lookup_tip_details (void *cls,
struct TALER_MERCHANTDB_PickupDetails **pickups)
{
struct PostgresClosure *pg = cls;
- uint64_t tip_serial;
+ uint64_t reward_serial;
enum GNUNET_DB_QueryStatus qs;
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_auto_from_type (tip_id),
+ GNUNET_PQ_query_param_auto_from_type (reward_id),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("tip_serial",
- &tip_serial),
+ GNUNET_PQ_result_spec_uint64 ("reward_serial",
+ &reward_serial),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
total_authorized),
TALER_PQ_RESULT_SPEC_AMOUNT ("picked_up",
@@ -3612,7 +3612,7 @@ postgres_lookup_tip_details (void *cls,
check_connection (pg);
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_tip_details",
+ "lookup_reward_details",
params,
rs);
if (qs <= 0)
@@ -3626,11 +3626,11 @@ postgres_lookup_tip_details (void *cls,
}
{
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&tip_serial),
+ GNUNET_PQ_query_param_uint64 (&reward_serial),
GNUNET_PQ_query_param_end
};
- struct LookupTipDetailsContext ltdc = {
+ struct LookupRewardDetailsContext ltdc = {
.pickups_length = pickups_length,
.pickups = pickups,
.pg = pg,
@@ -3650,16 +3650,16 @@ postgres_lookup_tip_details (void *cls,
/**
- * Insert details about a tip pickup operation. The @a total_picked_up
- * UPDATES the total amount under the @a tip_id, while the @a
+ * Insert details about a reward pickup operation. The @a total_picked_up
+ * UPDATES the total amount under the @a reward_id, while the @a
* total_requested is the amount to be associated with this @a pickup_id.
* While there is usually only one pickup event that picks up the entire
* amount, our schema allows for wallets to pick up the amount incrementally
- * over multiple pick up operations.
+ * over mulrewardle pick up operations.
*
* @param cls closure, typically a connection to the db
- * @param instance_id which instance gave the tip
- * @param tip_id the unique ID for the tip
+ * @param instance_id which instance gave the reward
+ * @param reward_id the unique ID for the reward
* @param total_picked_up how much was picked up overall at this
* point (includes @a total_requested)
* @param pickup_id unique ID for the operation
@@ -3671,7 +3671,7 @@ postgres_lookup_tip_details (void *cls,
static enum GNUNET_DB_QueryStatus
postgres_insert_pickup (void *cls,
const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
+ const struct TALER_RewardIdentifierP *reward_id,
const struct TALER_Amount *total_picked_up,
const struct TALER_PickupIdentifierP *pickup_id,
const struct TALER_Amount *total_requested)
@@ -3682,7 +3682,7 @@ postgres_insert_pickup (void *cls,
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_auto_from_type (tip_id),
+ GNUNET_PQ_query_param_auto_from_type (reward_id),
GNUNET_PQ_query_param_auto_from_type (pickup_id),
TALER_PQ_query_param_amount (total_requested),
GNUNET_PQ_query_param_end
@@ -3697,13 +3697,13 @@ postgres_insert_pickup (void *cls,
{
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (tip_id),
+ GNUNET_PQ_query_param_auto_from_type (reward_id),
TALER_PQ_query_param_amount (total_picked_up),
GNUNET_PQ_query_param_end
};
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "update_picked_up_tip",
+ "update_picked_up_reward",
params);
if (0 > qs)
return qs;
@@ -3714,13 +3714,13 @@ postgres_insert_pickup (void *cls,
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_auto_from_type (tip_id),
+ GNUNET_PQ_query_param_auto_from_type (reward_id),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("reserve_serial",
&reserve_serial),
- TALER_PQ_RESULT_SPEC_AMOUNT ("tips_picked_up",
+ TALER_PQ_RESULT_SPEC_AMOUNT ("rewards_picked_up",
&reserve_picked_up),
GNUNET_PQ_result_spec_end
@@ -3762,7 +3762,7 @@ postgres_insert_pickup (void *cls,
/**
* Insert blind signature obtained from the exchange during a
- * tip pickup operation.
+ * reward pickup operation.
*
* @param cls closure, typically a connection to the db
* @param pickup_id unique ID for the operation
@@ -5180,7 +5180,7 @@ postgres_connect (void *cls)
"($1, $2, $3, $4, $5, $6, $7, $8, $9)"),
/* For postgres_insert_reserve() */
GNUNET_PQ_make_prepare ("insert_reserve",
- "INSERT INTO merchant_tip_reserves"
+ "INSERT INTO merchant_reward_reserves"
"(reserve_pub"
",merchant_serial"
",creation_time"
@@ -5193,7 +5193,7 @@ postgres_connect (void *cls)
" WHERE merchant_id=$1"),
/* For postgres_activate_reserve() */
GNUNET_PQ_make_prepare ("activate_reserve",
- "UPDATE merchant_tip_reserves SET"
+ "UPDATE merchant_reward_reserves SET"
" exchange_initial_balance_val=$3"
",exchange_initial_balance_frac=$4"
" WHERE reserve_pub=$2"
@@ -5203,14 +5203,14 @@ postgres_connect (void *cls)
" WHERE merchant_id=$1)"),
/* For postgres_insert_reserve() */
GNUNET_PQ_make_prepare ("insert_reserve_key",
- "INSERT INTO merchant_tip_reserve_keys"
+ "INSERT INTO merchant_reward_reserve_keys"
"(reserve_serial"
",reserve_priv"
",exchange_url"
",master_pub"
")"
"SELECT reserve_serial, $3, $4, $5"
- " FROM merchant_tip_reserves"
+ " FROM merchant_reward_reserves"
" WHERE reserve_pub=$2"
" AND merchant_serial="
" (SELECT merchant_serial"
@@ -5224,9 +5224,9 @@ postgres_connect (void *cls)
",exchange_url"
",merchant_initial_balance_val"
",merchant_initial_balance_frac"
- " FROM merchant_tip_reserves"
+ " FROM merchant_reward_reserves"
" JOIN merchant_instances USING (merchant_serial)"
- " JOIN merchant_tip_reserve_keys USING (reserve_serial)"
+ " JOIN merchant_reward_reserve_keys USING (reserve_serial)"
" WHERE exchange_initial_balance_val=0"
" AND exchange_initial_balance_frac=0"),
/* For postgres_lookup_reserve() */
@@ -5238,31 +5238,31 @@ postgres_connect (void *cls)
",merchant_initial_balance_frac"
",exchange_initial_balance_val"
",exchange_initial_balance_frac"
- ",tips_committed_val"
- ",tips_committed_frac"
- ",tips_picked_up_val"
- ",tips_picked_up_frac"
+ ",rewards_committed_val"
+ ",rewards_committed_frac"
+ ",rewards_picked_up_val"
+ ",rewards_picked_up_frac"
",reserve_priv IS NOT NULL AS active"
",exchange_url"
",master_pub"
- " FROM merchant_tip_reserves"
- " FULL OUTER JOIN merchant_tip_reserve_keys USING (reserve_serial)"
+ " FROM merchant_reward_reserves"
+ " FULL OUTER JOIN merchant_reward_reserve_keys USING (reserve_serial)"
" WHERE reserve_pub = $2"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
/* For postgres_lookup_reserve() */
- GNUNET_PQ_make_prepare ("lookup_reserve_tips",
+ GNUNET_PQ_make_prepare ("lookup_reserve_rewards",
"SELECT"
" justification"
- ",tip_id"
+ ",reward_id"
",amount_val"
",amount_frac"
- " FROM merchant_tips"
+ " FROM merchant_rewards"
" WHERE reserve_serial ="
" (SELECT reserve_serial"
- " FROM merchant_tip_reserves"
+ " FROM merchant_reward_reserves"
" WHERE reserve_pub=$2"
" AND merchant_serial ="
" (SELECT merchant_serial"
@@ -5271,10 +5271,10 @@ postgres_connect (void *cls)
/* for postgres_delete_reserve() */
GNUNET_PQ_make_prepare ("delete_reserve",
"DELETE"
- " FROM merchant_tip_reserve_keys"
+ " FROM merchant_reward_reserve_keys"
" WHERE reserve_serial="
" (SELECT reserve_serial"
- " FROM merchant_tip_reserves"
+ " FROM merchant_reward_reserves"
" WHERE reserve_pub=$2"
" AND merchant_serial="
" (SELECT merchant_serial"
@@ -5283,57 +5283,57 @@ postgres_connect (void *cls)
/* for postgres_purge_reserve() */
GNUNET_PQ_make_prepare ("purge_reserve",
"DELETE"
- " FROM merchant_tip_reserves"
+ " FROM merchant_reward_reserves"
" WHERE reserve_pub=$2"
" AND merchant_serial="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
- /* For postgres_authorize_tip() */
- GNUNET_PQ_make_prepare ("lookup_reserve_for_tip",
+ /* For postgres_authorize_reward() */
+ GNUNET_PQ_make_prepare ("lookup_reserve_for_reward",
"SELECT"
" reserve_pub"
",expiration"
",exchange_initial_balance_val"
",exchange_initial_balance_frac"
- ",tips_committed_val"
- ",tips_committed_frac"
- " FROM merchant_tip_reserves"
+ ",rewards_committed_val"
+ ",rewards_committed_frac"
+ " FROM merchant_reward_reserves"
" WHERE"
" merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
- /* For postgres_authorize_tip() */
+ /* For postgres_authorize_reward() */
GNUNET_PQ_make_prepare ("lookup_reserve_status",
"SELECT"
" expiration"
",exchange_initial_balance_val"
",exchange_initial_balance_frac"
- ",tips_committed_val"
- ",tips_committed_frac"
- " FROM merchant_tip_reserves"
+ ",rewards_committed_val"
+ ",rewards_committed_frac"
+ " FROM merchant_reward_reserves"
" WHERE reserve_pub = $2"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
- /* For postgres_authorize_tip() */
- GNUNET_PQ_make_prepare ("update_reserve_tips_committed",
- "UPDATE merchant_tip_reserves SET"
- " tips_committed_val=$3"
- ",tips_committed_frac=$4"
+ /* For postgres_authorize_reward() */
+ GNUNET_PQ_make_prepare ("update_reserve_rewards_committed",
+ "UPDATE merchant_reward_reserves SET"
+ " rewards_committed_val=$3"
+ ",rewards_committed_frac=$4"
" WHERE reserve_pub = $2"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
- /* For postgres_authorize_tip() */
- GNUNET_PQ_make_prepare ("insert_tip",
- "INSERT INTO merchant_tips"
+ /* For postgres_authorize_reward() */
+ GNUNET_PQ_make_prepare ("insert_reward",
+ "INSERT INTO merchant_rewards"
"(reserve_serial"
- ",tip_id"
+ ",reward_id"
",justification"
",next_url"
",expiration"
@@ -5342,7 +5342,7 @@ postgres_connect (void *cls)
") "
"SELECT"
" reserve_serial, $3, $4, $5, $6, $7, $8"
- " FROM merchant_tip_reserves"
+ " FROM merchant_reward_reserves"
" WHERE reserve_pub=$2"
" AND merchant_serial = "
" (SELECT merchant_serial"
@@ -5354,12 +5354,12 @@ postgres_connect (void *cls)
" exchange_url"
",reserve_priv"
",pickup_serial"
- " FROM merchant_tip_pickups"
- " JOIN merchant_tips USING (tip_serial)"
- " JOIN merchant_tip_reserves USING (reserve_serial)"
- " JOIN merchant_tip_reserve_keys USING (reserve_serial)"
+ " FROM merchant_reward_pickups"
+ " JOIN merchant_rewards USING (reward_serial)"
+ " JOIN merchant_reward_reserves USING (reserve_serial)"
+ " JOIN merchant_reward_reserve_keys USING (reserve_serial)"
" WHERE pickup_id = $3"
- " AND tip_id = $2"
+ " AND reward_id = $2"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
@@ -5369,183 +5369,183 @@ postgres_connect (void *cls)
"SELECT"
" coin_offset"
",blind_sig"
- " FROM merchant_tip_pickup_signatures"
+ " FROM merchant_reward_pickup_signatures"
" WHERE pickup_serial = $1"),
- /* For postgres_lookup_tip() */
- GNUNET_PQ_make_prepare ("lookup_tip",
+ /* For postgres_lookup_reward() */
+ GNUNET_PQ_make_prepare ("lookup_reward",
"SELECT"
" amount_val"
",amount_frac"
",picked_up_val"
",picked_up_frac"
- ",merchant_tips.expiration"
+ ",merchant_rewards.expiration"
",exchange_url"
",next_url"
",reserve_priv"
- " FROM merchant_tips"
- " JOIN merchant_tip_reserves USING (reserve_serial)"
- " JOIN merchant_tip_reserve_keys USING (reserve_serial)"
- " WHERE tip_id = $2"
+ " FROM merchant_rewards"
+ " JOIN merchant_reward_reserves USING (reserve_serial)"
+ " JOIN merchant_reward_reserve_keys USING (reserve_serial)"
+ " WHERE reward_id = $2"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
- /* For postgres_lookup_tip() */
- GNUNET_PQ_make_prepare ("lookup_tips_inc",
+ /* For postgres_lookup_reward() */
+ GNUNET_PQ_make_prepare ("lookup_rewards_inc",
"SELECT"
- " tip_serial"
- ",tip_id"
+ " reward_serial"
+ ",reward_id"
",amount_val"
",amount_frac"
",CAST($4 as BIGINT)" /* otherwise $4 is unused and Postgres unhappy */
",CAST($5 as BOOL)" /* otherwise $5 is unused and Postgres unhappy */
- " FROM merchant_tips"
- " JOIN merchant_tip_reserves USING (reserve_serial)"
+ " FROM merchant_rewards"
+ " JOIN merchant_reward_reserves USING (reserve_serial)"
" WHERE merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"
" AND"
- " tip_serial > $3"
- " ORDER BY tip_serial ASC"
+ " reward_serial > $3"
+ " ORDER BY reward_serial ASC"
" LIMIT $2"),
- GNUNET_PQ_make_prepare ("lookup_tips_dec",
+ GNUNET_PQ_make_prepare ("lookup_rewards_dec",
"SELECT"
- " tip_serial"
- ",tip_id"
+ " reward_serial"
+ ",reward_id"
",amount_val"
",amount_frac"
",CAST($4 as BIGINT)" /* otherwise $4 is unused and Postgres unhappy */
",CAST($5 as BOOL)" /* otherwise $5 is unused and Postgres unhappy */
- " FROM merchant_tips"
- " JOIN merchant_tip_reserves USING (reserve_serial)"
+ " FROM merchant_rewards"
+ " JOIN merchant_reward_reserves USING (reserve_serial)"
" WHERE merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"
" AND"
- " tip_serial < $3"
- " ORDER BY tip_serial DESC"
+ " reward_serial < $3"
+ " ORDER BY reward_serial DESC"
" LIMIT $2"),
- GNUNET_PQ_make_prepare ("lookup_tips_inc_expired",
+ GNUNET_PQ_make_prepare ("lookup_rewards_inc_expired",
"SELECT"
- " tip_serial"
- ",tip_id"
+ " reward_serial"
+ ",reward_id"
",amount_val"
",amount_frac"
- " FROM merchant_tips"
- " JOIN merchant_tip_reserves USING (reserve_serial)"
+ " FROM merchant_rewards"
+ " JOIN merchant_reward_reserves USING (reserve_serial)"
" WHERE merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"
" AND"
- " tip_serial > $3"
+ " reward_serial > $3"
" AND"
- " CAST($5 as BOOL) = (merchant_tips.expiration < $4)"
- " ORDER BY tip_serial ASC"
+ " CAST($5 as BOOL) = (merchant_rewards.expiration < $4)"
+ " ORDER BY reward_serial ASC"
" LIMIT $2"),
- GNUNET_PQ_make_prepare ("lookup_tips_dec_expired",
+ GNUNET_PQ_make_prepare ("lookup_rewards_dec_expired",
"SELECT"
- " tip_serial"
- ",tip_id"
+ " reward_serial"
+ ",reward_id"
",amount_val"
",amount_frac"
- " FROM merchant_tips"
- " JOIN merchant_tip_reserves USING (reserve_serial)"
+ " FROM merchant_rewards"
+ " JOIN merchant_reward_reserves USING (reserve_serial)"
" WHERE merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"
" AND"
- " tip_serial < $3"
+ " reward_serial < $3"
" AND"
- " CAST($5 as BOOL) = (merchant_tips.expiration < $4)"
- " ORDER BY tip_serial DESC"
+ " CAST($5 as BOOL) = (merchant_rewards.expiration < $4)"
+ " ORDER BY reward_serial DESC"
" LIMIT $2"),
- /* for postgres_lookup_tip_details() */
- GNUNET_PQ_make_prepare ("lookup_tip_details",
+ /* for postgres_lookup_reward_details() */
+ GNUNET_PQ_make_prepare ("lookup_reward_details",
"SELECT"
- " tip_serial"
+ " reward_serial"
",amount_val"
",amount_frac"
",picked_up_val"
",picked_up_frac"
",justification"
- ",merchant_tips.expiration"
+ ",merchant_rewards.expiration"
",reserve_pub"
- " FROM merchant_tips"
- " JOIN merchant_tip_reserves USING (reserve_serial)"
- " WHERE tip_id = $2"
+ " FROM merchant_rewards"
+ " JOIN merchant_reward_reserves USING (reserve_serial)"
+ " WHERE reward_id = $2"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
- /* for postgres_lookup_tip_details() */
+ /* for postgres_lookup_reward_details() */
GNUNET_PQ_make_prepare ("lookup_pickup_details",
"SELECT"
" pickup_id"
",amount_val"
",amount_frac"
",COUNT(blind_sig) AS num_planchets"
- " FROM merchant_tip_pickups"
- " JOIN merchant_tip_pickup_signatures USING (pickup_serial)"
- " WHERE tip_serial = $1"
+ " FROM merchant_reward_pickups"
+ " JOIN merchant_reward_pickup_signatures USING (pickup_serial)"
+ " WHERE reward_serial = $1"
" GROUP BY pickup_serial"),
/* for postgres_insert_pickup() */
GNUNET_PQ_make_prepare ("insert_pickup",
- "INSERT INTO merchant_tip_pickups"
- "(tip_serial"
+ "INSERT INTO merchant_reward_pickups"
+ "(reward_serial"
",pickup_id"
",amount_val"
",amount_frac"
") "
"SELECT"
- " tip_serial, $3, $4, $5"
- " FROM merchant_tips"
- " JOIN merchant_tip_reserves USING (reserve_serial)"
- " WHERE tip_id=$2"
+ " reward_serial, $3, $4, $5"
+ " FROM merchant_rewards"
+ " JOIN merchant_reward_reserves USING (reserve_serial)"
+ " WHERE reward_id=$2"
" AND merchant_serial = "
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
/* for postgres_insert_pickup() */
- GNUNET_PQ_make_prepare ("update_picked_up_tip",
- "UPDATE merchant_tips SET"
+ GNUNET_PQ_make_prepare ("update_picked_up_reward",
+ "UPDATE merchant_rewards SET"
" picked_up_val=$2"
",picked_up_frac=$3"
",was_picked_up = ($2 = amount_val AND $3 = amount_frac)"
- " WHERE tip_id = $1"),
+ " WHERE reward_id = $1"),
/* for postgres_insert_pickup() */
GNUNET_PQ_make_prepare ("lookup_picked_up_reserve",
"SELECT"
" reserve_serial"
- ",tips_picked_up_val"
- ",tips_picked_up_frac"
- " FROM merchant_tip_reserves"
- " JOIN merchant_tips USING (reserve_serial)"
- " WHERE tip_id=$2"
+ ",rewards_picked_up_val"
+ ",rewards_picked_up_frac"
+ " FROM merchant_reward_reserves"
+ " JOIN merchant_rewards USING (reserve_serial)"
+ " WHERE reward_id=$2"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)"),
/* for postgres_insert_pickup() */
GNUNET_PQ_make_prepare ("update_picked_up_reserve",
- "UPDATE merchant_tip_reserves SET"
- " tips_picked_up_val=$2"
- ",tips_picked_up_frac=$3"
+ "UPDATE merchant_reward_reserves SET"
+ " rewards_picked_up_val=$2"
+ ",rewards_picked_up_frac=$3"
" WHERE reserve_serial = $1"),
/* for postgres_insert_pickup_blind_signature() */
GNUNET_PQ_make_prepare ("insert_pickup_blind_signature",
- "INSERT INTO merchant_tip_pickup_signatures"
+ "INSERT INTO merchant_reward_pickup_signatures"
"(pickup_serial"
",coin_offset"
",blind_sig"
") "
"SELECT"
" pickup_serial, $2, $3"
- " FROM merchant_tip_pickups"
+ " FROM merchant_reward_pickups"
" WHERE pickup_id=$1"),
/* for postgres_lookup_templates() */
GNUNET_PQ_make_prepare ("lookup_templates",
@@ -5936,11 +5936,11 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
plugin->lookup_reserve = &postgres_lookup_reserve;
plugin->delete_reserve = &postgres_delete_reserve;
plugin->purge_reserve = &postgres_purge_reserve;
- plugin->authorize_tip = &postgres_authorize_tip;
+ plugin->authorize_reward = &postgres_authorize_reward;
plugin->lookup_pickup = &postgres_lookup_pickup;
- plugin->lookup_tip = &postgres_lookup_tip;
- plugin->lookup_tips = &postgres_lookup_tips;
- plugin->lookup_tip_details = &postgres_lookup_tip_details;
+ plugin->lookup_reward = &postgres_lookup_reward;
+ plugin->lookup_rewards = &postgres_lookup_rewards;
+ plugin->lookup_reward_details = &postgres_lookup_reward_details;
plugin->insert_pickup = &postgres_insert_pickup;
plugin->insert_pickup_blind_signature =
&postgres_insert_pickup_blind_signature;