prop224: hs_time_between_tp_and_srv() -> hs_in_period_between_tp_and_srv()

Conflicts:
	src/or/nodelist.c
This commit is contained in:
George Kadianakis 2017-09-08 19:06:20 +03:00
parent eb81a8e69c
commit e7bdb9eedc
6 changed files with 18 additions and 16 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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,

View file

@ -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

View file

@ -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 {

View file

@ -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. */