prop224: 'is_new_tp' -> 'use_second_hdsir_index' in hs_get_responsible_hsdirs()

This commit is contained in:
George Kadianakis 2017-09-08 12:51:30 +03:00
parent 6c6ba07517
commit eb81a8e69c
2 changed files with 9 additions and 8 deletions

View File

@ -1277,18 +1277,18 @@ node_has_hsdir_index(const node_t *node)
/* For a given blinded key and time period number, get the responsible HSDir /* For a given blinded key and time period number, get the responsible HSDir
* and put their routerstatus_t object in the responsible_dirs list. If * and put their routerstatus_t object in the responsible_dirs list. If
* is_next_period is true, the next hsdir_index of the node_t is used. If * 'use_second_hsdir_index' is true, use the second hsdir_index of the node_t
* 'for_fetching' is true, the spread fetch consensus parameter is used else * is used. If 'for_fetching' is true, the spread fetch consensus parameter is
* the spread store is used which is only for upload. This function can't fail * used else the spread store is used which is only for upload. This function
* but it is possible that the responsible_dirs list contains fewer nodes than * can't fail but it is possible that the responsible_dirs list contains fewer
* expected. * nodes than expected.
* *
* This function goes over the latest consensus routerstatus list and sorts it * This function goes over the latest consensus routerstatus list and sorts it
* by their node_t hsdir_index then does a binary search to find the closest * by their node_t hsdir_index then does a binary search to find the closest
* node. All of this makes it a bit CPU intensive so use it wisely. */ * node. All of this makes it a bit CPU intensive so use it wisely. */
void void
hs_get_responsible_hsdirs(const ed25519_public_key_t *blinded_pk, hs_get_responsible_hsdirs(const ed25519_public_key_t *blinded_pk,
uint64_t time_period_num, int is_new_tp, uint64_t time_period_num, int use_second_hsdir_index,
int for_fetching, smartlist_t *responsible_dirs) int for_fetching, smartlist_t *responsible_dirs)
{ {
smartlist_t *sorted_nodes; smartlist_t *sorted_nodes;
@ -1336,7 +1336,7 @@ hs_get_responsible_hsdirs(const ed25519_public_key_t *blinded_pk,
if (for_fetching) { if (for_fetching) {
smartlist_sort(sorted_nodes, compare_node_fetch_hsdir_index); smartlist_sort(sorted_nodes, compare_node_fetch_hsdir_index);
cmp_fct = compare_digest_to_fetch_hsdir_index; cmp_fct = compare_digest_to_fetch_hsdir_index;
} else if (is_new_tp) { } else if (use_second_hsdir_index) {
smartlist_sort(sorted_nodes, compare_node_store_second_hsdir_index); smartlist_sort(sorted_nodes, compare_node_store_second_hsdir_index);
cmp_fct = compare_digest_to_store_second_hsdir_index; cmp_fct = compare_digest_to_store_second_hsdir_index;
} else { } else {

View File

@ -224,7 +224,8 @@ int32_t hs_get_hsdir_spread_fetch(void);
int32_t hs_get_hsdir_spread_store(void); int32_t hs_get_hsdir_spread_store(void);
void hs_get_responsible_hsdirs(const ed25519_public_key_t *blinded_pk, void hs_get_responsible_hsdirs(const ed25519_public_key_t *blinded_pk,
uint64_t time_period_num, int is_next_period, uint64_t time_period_num,
int use_second_hsdir_index,
int for_fetching, smartlist_t *responsible_dirs); int for_fetching, smartlist_t *responsible_dirs);
routerstatus_t *hs_pick_hsdir(smartlist_t *responsible_dirs, routerstatus_t *hs_pick_hsdir(smartlist_t *responsible_dirs,
const char *req_key_str); const char *req_key_str);