Browse Source

prop224: hs_time_between_tp_and_srv() -> hs_in_period_between_tp_and_srv()

Conflicts:
	src/or/nodelist.c
George Kadianakis 6 years ago
parent
commit
e7bdb9eedc
6 changed files with 18 additions and 16 deletions
  1. 1 1
      src/or/hs_client.c
  2. 1 1
      src/or/hs_common.c
  3. 1 1
      src/or/hs_common.h
  4. 2 2
      src/or/hs_service.c
  5. 4 3
      src/or/nodelist.c
  6. 9 8
      src/test/test_hs_common.c

+ 1 - 1
src/or/hs_client.c

@@ -183,7 +183,7 @@ pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk)
   }
 
   /* Get responsible hsdirs of service for this time period */
-  is_new_tp = hs_time_between_tp_and_srv(NULL, time(NULL));
+  is_new_tp = hs_in_period_between_tp_and_srv(NULL, time(NULL));
   hs_get_responsible_hsdirs(&blinded_pubkey, current_time_period,
                             is_new_tp, 1, responsible_hsdirs);
 

+ 1 - 1
src/or/hs_common.c

@@ -1049,7 +1049,7 @@ hs_build_blinded_keypair(const ed25519_keypair_t *kp,
  *    +------------------------------------------------------------------+
  */
 MOCK_IMPL(int,
-hs_time_between_tp_and_srv, (const networkstatus_t *consensus, time_t now))
+hs_in_period_between_tp_and_srv,(const networkstatus_t *consensus, time_t now))
 {
   time_t valid_after;
   time_t srv_start_time, tp_start_time;

+ 1 - 1
src/or/hs_common.h

@@ -204,7 +204,7 @@ time_t hs_get_start_time_of_next_time_period(time_t now);
 
 link_specifier_t *hs_link_specifier_dup(const link_specifier_t *lspec);
 
-MOCK_DECL(int, hs_time_between_tp_and_srv,
+MOCK_DECL(int, hs_in_period_between_tp_and_srv,
           (const networkstatus_t *consensus, time_t now));
 
 uint8_t *hs_get_current_srv(uint64_t time_period_num,

+ 2 - 2
src/or/hs_service.c

@@ -1398,7 +1398,7 @@ build_descriptors_for_new_service(hs_service_t *service, time_t now)
    * TP#1 and next TP#2.
    */
 
-  if (hs_time_between_tp_and_srv(NULL, now)) {
+  if (hs_in_period_between_tp_and_srv(NULL, now)) {
     /* Case B from the above, inside of the new time period. */
     current_desc_tp = hs_get_previous_time_period_num(0); /* TP#1 */
     next_desc_tp = hs_get_time_period_num(0);             /* TP#2 */
@@ -2390,7 +2390,7 @@ upload_descriptor_to_all(const hs_service_t *service,
 
   /* Do we have a new TP that is are we between a new time period and the next
    * SRV creation? */
-  is_new_tp = hs_time_between_tp_and_srv(NULL, approx_time());
+  is_new_tp = hs_in_period_between_tp_and_srv(NULL, approx_time());
   /* Get our list of responsible HSDir. */
   responsible_dirs = smartlist_new();
   /* The parameter 0 means that we aren't a client so tell the function to use

+ 4 - 3
src/or/nodelist.c

@@ -210,7 +210,8 @@ node_set_hsdir_index(node_t *node, const networkstatus_t *ns)
   /* We always use the current time period for fetching descs */
   fetch_tp = current_time_period_num;
 
-  if (hs_time_between_tp_and_srv(ns, now)) {
+  /* Now extract the needed SRVs and time periods for building hsdir indices */
+  if (hs_in_period_between_tp_and_srv(ns, now)) {
     fetch_srv = hs_get_current_srv(fetch_tp, ns);
 
     store_first_tp = hs_get_previous_time_period_num(0);
@@ -233,7 +234,7 @@ node_set_hsdir_index(node_t *node, const networkstatus_t *ns)
 
   /* If we are in the time segment between SRV#N and TP#N, the fetch index is
      the same as the first store index */
-  if (!hs_time_between_tp_and_srv(ns, now)) {
+  if (!hs_in_period_between_tp_and_srv(ns, now)) {
     memcpy(node->hsdir_index->store_first, node->hsdir_index->fetch,
            sizeof(node->hsdir_index->store_first));
   } else {
@@ -243,7 +244,7 @@ node_set_hsdir_index(node_t *node, const networkstatus_t *ns)
 
   /* If we are in the time segment between TP#N and SRV#N+1, the fetch index is
      the same as the second store index */
-  if (hs_time_between_tp_and_srv(ns, now)) {
+  if (hs_in_period_between_tp_and_srv(ns, now)) {
     memcpy(node->hsdir_index->store_second, node->hsdir_index->fetch,
            sizeof(node->hsdir_index->store_second));
   } else {

+ 9 - 8
src/test/test_hs_common.c

@@ -786,27 +786,27 @@ test_time_between_tp_and_srv(void *arg)
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 00:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 0);
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 11:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 0);
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 12:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 1);
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 23:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 1);
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 00:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 0);
 
  done:
@@ -1065,7 +1065,8 @@ typedef struct reachability_cfg_t {
 
   /* Is the client and service expected to be in a new time period. After
    * setting the consensus time, the reachability test checks
-   * hs_time_between_tp_and_srv() and test the returned value against this. */
+   * hs_in_period_between_tp_and_srv() and test the returned value against
+   * this. */
   unsigned int service_in_new_tp;
   unsigned int client_in_new_tp;
 
@@ -1300,9 +1301,9 @@ run_reachability_scenario(const reachability_cfg_t *cfg, int num_scenario)
                       &mock_client_ns->fresh_until);
 
   /* New time period checks for this scenario. */
-  tt_int_op(hs_time_between_tp_and_srv(mock_service_ns, 0), OP_EQ,
+  tt_int_op(hs_in_period_between_tp_and_srv(mock_service_ns, 0), OP_EQ,
             cfg->service_in_new_tp);
-  tt_int_op(hs_time_between_tp_and_srv(mock_client_ns, 0), OP_EQ,
+  tt_int_op(hs_in_period_between_tp_and_srv(mock_client_ns, 0), OP_EQ,
             cfg->client_in_new_tp);
 
   /* Set the SRVs for this scenario. */