conscache.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef TOR_CONSCACHE_H
  4. #define TOR_CONSCACHE_H
  5. #include "handles.h"
  6. typedef struct consensus_cache_entry_t consensus_cache_entry_t;
  7. typedef struct consensus_cache_t consensus_cache_t;
  8. HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, )
  9. consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
  10. void consensus_cache_free(consensus_cache_t *cache);
  11. struct sandbox_cfg_elem;
  12. int consensus_cache_register_with_sandbox(consensus_cache_t *cache,
  13. struct sandbox_cfg_elem **cfg);
  14. void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
  15. void consensus_cache_delete_pending(consensus_cache_t *cache,
  16. int force);
  17. int consensus_cache_get_n_filenames_available(consensus_cache_t *cache);
  18. consensus_cache_entry_t *consensus_cache_add(consensus_cache_t *cache,
  19. const config_line_t *labels,
  20. const uint8_t *data,
  21. size_t datalen);
  22. consensus_cache_entry_t *consensus_cache_find_first(
  23. consensus_cache_t *cache,
  24. const char *key,
  25. const char *value);
  26. void consensus_cache_find_all(smartlist_t *out,
  27. consensus_cache_t *cache,
  28. const char *key,
  29. const char *value);
  30. void consensus_cache_filter_list(smartlist_t *lst,
  31. const char *key,
  32. const char *value);
  33. const char *consensus_cache_entry_get_value(const consensus_cache_entry_t *ent,
  34. const char *key);
  35. const config_line_t *consensus_cache_entry_get_labels(
  36. const consensus_cache_entry_t *ent);
  37. void consensus_cache_entry_incref(consensus_cache_entry_t *ent);
  38. void consensus_cache_entry_decref(consensus_cache_entry_t *ent);
  39. void consensus_cache_entry_mark_for_removal(consensus_cache_entry_t *ent);
  40. void consensus_cache_entry_mark_for_aggressive_release(
  41. consensus_cache_entry_t *ent);
  42. int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent,
  43. const uint8_t **body_out,
  44. size_t *sz_out);
  45. #ifdef TOR_UNIT_TESTS
  46. int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent);
  47. #endif
  48. #endif