aboutsummaryrefslogtreecommitdiff
path: root/src/backend/anastasis-httpd_truth_upload.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/anastasis-httpd_truth_upload.c')
-rw-r--r--src/backend/anastasis-httpd_truth_upload.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/backend/anastasis-httpd_truth_upload.c b/src/backend/anastasis-httpd_truth_upload.c
index e4bce9c..ddf645c 100644
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth_upload.c
@@ -526,7 +526,7 @@ AH_handler_truth_post (
526 const char *type; 526 const char *type;
527 enum GNUNET_DB_QueryStatus qs; 527 enum GNUNET_DB_QueryStatus qs;
528 uint32_t storage_years; 528 uint32_t storage_years;
529 struct GNUNET_TIME_Absolute paid_until; 529 struct GNUNET_TIME_Timestamp paid_until;
530 struct GNUNET_JSON_Specification spec[] = { 530 struct GNUNET_JSON_Specification spec[] = {
531 GNUNET_JSON_spec_fixed_auto ("key_share_data", 531 GNUNET_JSON_spec_fixed_auto ("key_share_data",
532 &key_share_data), 532 &key_share_data),
@@ -703,11 +703,11 @@ AH_handler_truth_post (
703 if (0 != TALER_amount_cmp (&AH_truth_upload_fee, 703 if (0 != TALER_amount_cmp (&AH_truth_upload_fee,
704 &zero_amount)) 704 &zero_amount))
705 { 705 {
706 struct GNUNET_TIME_Absolute desired_until; 706 struct GNUNET_TIME_Timestamp desired_until;
707 enum GNUNET_DB_QueryStatus qs; 707 enum GNUNET_DB_QueryStatus qs;
708 708
709 desired_until 709 desired_until
710 = GNUNET_TIME_relative_to_absolute ( 710 = GNUNET_TIME_relative_to_timestamp (
711 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 711 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
712 storage_years)); 712 storage_years));
713 qs = db->check_truth_upload_paid (db->cls, 713 qs = db->check_truth_upload_paid (db->cls,
@@ -719,16 +719,16 @@ AH_handler_truth_post (
719 TALER_EC_GENERIC_DB_FETCH_FAILED, 719 TALER_EC_GENERIC_DB_FETCH_FAILED,
720 NULL); 720 NULL);
721 if ( (0 == qs) || 721 if ( (0 == qs) ||
722 (paid_until.abs_value_us < desired_until.abs_value_us) ) 722 (GNUNET_TIME_timestamp_cmp (paid_until,
723 <,
724 desired_until) ) )
723 { 725 {
724 struct GNUNET_TIME_Absolute now;
725 struct GNUNET_TIME_Relative rem; 726 struct GNUNET_TIME_Relative rem;
726 727
727 now = GNUNET_TIME_absolute_get (); 728 if (GNUNET_TIME_absolute_is_past (paid_until.abs_time))
728 if (paid_until.abs_value_us < now.abs_value_us) 729 paid_until = GNUNET_TIME_timestamp_get ();
729 paid_until = now; 730 rem = GNUNET_TIME_absolute_get_difference (paid_until.abs_time,
730 rem = GNUNET_TIME_absolute_get_difference (paid_until, 731 desired_until.abs_time);
731 desired_until);
732 tuc->years_to_pay = rem.rel_value_us 732 tuc->years_to_pay = rem.rel_value_us
733 / GNUNET_TIME_UNIT_YEARS.rel_value_us; 733 / GNUNET_TIME_UNIT_YEARS.rel_value_us;
734 if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) 734 if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
@@ -755,16 +755,16 @@ AH_handler_truth_post (
755 } 755 }
756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
757 "TRUTH paid until %s (%d)!\n", 757 "TRUTH paid until %s (%d)!\n",
758 GNUNET_STRINGS_relative_time_to_string ( 758 GNUNET_TIME_relative2s (
759 GNUNET_TIME_absolute_get_remaining ( 759 GNUNET_TIME_absolute_get_remaining (
760 paid_until), 760 paid_until.abs_time),
761 GNUNET_YES), 761 GNUNET_YES),
762 qs); 762 qs);
763 } 763 }
764 else 764 else
765 { 765 {
766 paid_until 766 paid_until
767 = GNUNET_TIME_relative_to_absolute ( 767 = GNUNET_TIME_relative_to_timestamp (
768 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 768 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
769 ANASTASIS_MAX_YEARS_STORAGE)); 769 ANASTASIS_MAX_YEARS_STORAGE));
770 } 770 }
@@ -773,7 +773,7 @@ AH_handler_truth_post (
773 773
774 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 774 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
775 "Storing truth until %s!\n", 775 "Storing truth until %s!\n",
776 GNUNET_STRINGS_absolute_time_to_string (paid_until)); 776 GNUNET_TIME_timestamp2s (paid_until));
777 qs = db->store_truth (db->cls, 777 qs = db->store_truth (db->cls,
778 truth_uuid, 778 truth_uuid,
779 &key_share_data, 779 &key_share_data,
@@ -783,7 +783,8 @@ AH_handler_truth_post (
783 encrypted_truth, 783 encrypted_truth,
784 encrypted_truth_size, 784 encrypted_truth_size,
785 type, 785 type,
786 GNUNET_TIME_absolute_get_remaining (paid_until)); 786 GNUNET_TIME_absolute_get_remaining (
787 paid_until.abs_time));
787 switch (qs) 788 switch (qs)
788 { 789 {
789 case GNUNET_DB_STATUS_HARD_ERROR: 790 case GNUNET_DB_STATUS_HARD_ERROR: