summaryrefslogtreecommitdiff
path: root/src/stasis
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-12-31 21:04:08 +0100
committerChristian Grothoff <christian@grothoff.org>2021-12-31 21:04:08 +0100
commita261b98c73643a16e70ce4f22ed7cd8838967689 (patch)
tree6cba2431af86894ee481e811f53dbde787dd98e3 /src/stasis
parent0919fe8b52588bd8f3adb83817158abc9434ac5b (diff)
downloadanastasis-a261b98c73643a16e70ce4f22ed7cd8838967689.tar.gz
anastasis-a261b98c73643a16e70ce4f22ed7cd8838967689.tar.bz2
anastasis-a261b98c73643a16e70ce4f22ed7cd8838967689.zip
default to account expiration minimum of 1 year
Diffstat (limited to 'src/stasis')
-rw-r--r--src/stasis/plugin_anastasis_postgres.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c
index 6bb7f32..b2391f8 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -1051,7 +1051,8 @@ retry:
/**
- * Increment account lifetime.
+ * Increment account lifetime based on payment having been received.
+ * Does nothing if the payment is not new.
*
* @param cls closure
* @param account_pub which account received a payment
@@ -1071,6 +1072,11 @@ postgres_increment_lifetime (
struct PostgresClosure *pg = cls;
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Incrementing lifetime of account %s based on payment by %s\n",
+ TALER_B2S (account_pub),
+ GNUNET_TIME_relative2s (lifetime,
+ true));
check_connection (pg);
for (unsigned int retries = 0; retries<MAX_RETRIES; retries++)
{
@@ -1100,9 +1106,11 @@ postgres_increment_lifetime (
case GNUNET_DB_STATUS_SOFT_ERROR:
goto retry;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ /* Payment not new or payment request unknown. */
/* continued below */
break;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ /* Payment just now marked as 'paid' */
/* continued below */
break;
}
@@ -1152,6 +1160,11 @@ postgres_increment_lifetime (
expiration = GNUNET_TIME_relative_to_timestamp (lifetime);
GNUNET_break (! GNUNET_TIME_absolute_is_never (expiration.abs_time));
*paid_until = expiration;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Creating new account %s with initial lifetime of %s\n",
+ TALER_B2S (account_pub),
+ GNUNET_TIME_relative2s (lifetime,
+ true));
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"user_insert",
params);
@@ -1160,7 +1173,8 @@ postgres_increment_lifetime (
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
{
- /* existing rec doc payment, return expiration */
+ /* existing rec doc payment (payment replay), return
+ existing expiration */
*paid_until = expiration;
rollback (pg);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1171,13 +1185,18 @@ postgres_increment_lifetime (
}
else
{
- /* user exists, update expiration_date */
+ /* user exists, payment is new, update expiration_date */
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_timestamp (&expiration),
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_end
};
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Incrementing lifetime of account %s by %s\n",
+ TALER_B2S (account_pub),
+ GNUNET_TIME_relative2s (lifetime,
+ true));
expiration
= GNUNET_TIME_absolute_to_timestamp (
GNUNET_TIME_absolute_add (expiration.abs_time,