shared_random_client.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright (c) 2018-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file shared_random_client.h
  5. * \brief Header file for shared_random_client.c.
  6. **/
  7. #ifndef TOR_SHARED_RANDOM_CLIENT_H
  8. #define TOR_SHARED_RANDOM_CLIENT_H
  9. /* Dirauth module. */
  10. #include "feature/dirauth/shared_random.h"
  11. /* Helper functions. */
  12. void sr_srv_encode(char *dst, size_t dst_len, const sr_srv_t *srv);
  13. int get_voting_interval(void);
  14. /* Control port functions. */
  15. char *sr_get_current_for_control(void);
  16. char *sr_get_previous_for_control(void);
  17. /* SRV functions. */
  18. const sr_srv_t *sr_get_current(const networkstatus_t *ns);
  19. const sr_srv_t *sr_get_previous(const networkstatus_t *ns);
  20. sr_srv_t *sr_parse_srv(const smartlist_t *args);
  21. /*
  22. * Shared Random State API
  23. */
  24. /* Each protocol phase has 12 rounds */
  25. #define SHARED_RANDOM_N_ROUNDS 12
  26. /* Number of phase we have in a protocol. */
  27. #define SHARED_RANDOM_N_PHASES 2
  28. time_t sr_state_get_start_time_of_current_protocol_run(void);
  29. time_t sr_state_get_start_time_of_previous_protocol_run(void);
  30. unsigned int sr_state_get_phase_duration(void);
  31. unsigned int sr_state_get_protocol_run_duration(void);
  32. time_t get_start_time_of_current_round(void);
  33. #ifdef TOR_UNIT_TESTS
  34. #endif /* TOR_UNIT_TESTS */
  35. #endif /* !defined(TOR_SHARED_RANDOM_CLIENT_H) */