mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
prop224: Build hsdir index for node_t
This hsdir index value is used to give an index value to all node_t (relays) that supports HSDir v3. An index value is then computed using the blinded key to know where to fetch/upload the service descriptor from/to. To avoid computing that index value everytime the client/service needs it, we do that everytime we get a new consensus which then doesn't change until the next one. The downside is that we need to sort them once we need to compute the set of responsible HSDir. Finally, the "hs_index" function is also added but not used. It will be used in later commits to compute which node_t is a responsible HSDir for the service we want to fetch/upload the descriptor. Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
committed by
Nick Mathewson
parent
77b279c35c
commit
267bc7bc3b
@@ -1390,6 +1390,30 @@ sr_get_previous_for_control(void)
|
||||
return srv_str;
|
||||
}
|
||||
|
||||
/* Return current shared random value from the latest consensus. Caller can
|
||||
* NOT keep a reference to the returned pointer. Return NULL if none. */
|
||||
const sr_srv_t *
|
||||
sr_get_current(void)
|
||||
{
|
||||
const networkstatus_t *c = networkstatus_get_latest_consensus();
|
||||
if (c) {
|
||||
return c->sr_info.current_srv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return previous shared random value from the latest consensus. Caller can
|
||||
* NOT keep a reference to the returned pointer. Return NULL if none. */
|
||||
const sr_srv_t *
|
||||
sr_get_previous(void)
|
||||
{
|
||||
const networkstatus_t *c = networkstatus_get_latest_consensus();
|
||||
if (c) {
|
||||
return c->sr_info.previous_srv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TOR_UNIT_TESTS
|
||||
|
||||
/* Set the global value of number of SRV agreements so the test can play
|
||||
|
||||
Reference in New Issue
Block a user