conscache.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #define consensus_cache_entry_handle_free(h) \
  10. FREE_AND_NULL(consensus_cache_entry_handle, (h))
  11. consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
  12. void consensus_cache_free(consensus_cache_t *cache);
  13. struct sandbox_cfg_elem;
  14. int consensus_cache_may_overallocate(consensus_cache_t *cache);
  15. int consensus_cache_register_with_sandbox(consensus_cache_t *cache,
  16. struct sandbox_cfg_elem **cfg);
  17. void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
  18. void consensus_cache_delete_pending(consensus_cache_t *cache,
  19. int force);
  20. int consensus_cache_get_n_filenames_available(consensus_cache_t *cache);
  21. consensus_cache_entry_t *consensus_cache_add(consensus_cache_t *cache,
  22. const config_line_t *labels,
  23. const uint8_t *data,
  24. size_t datalen);
  25. consensus_cache_entry_t *consensus_cache_find_first(
  26. consensus_cache_t *cache,
  27. const char *key,
  28. const char *value);
  29. void consensus_cache_find_all(smartlist_t *out,
  30. consensus_cache_t *cache,
  31. const char *key,
  32. const char *value);
  33. void consensus_cache_filter_list(smartlist_t *lst,
  34. const char *key,
  35. const char *value);
  36. const char *consensus_cache_entry_get_value(const consensus_cache_entry_t *ent,
  37. const char *key);
  38. const config_line_t *consensus_cache_entry_get_labels(
  39. const consensus_cache_entry_t *ent);
  40. void consensus_cache_entry_incref(consensus_cache_entry_t *ent);
  41. void consensus_cache_entry_decref(consensus_cache_entry_t *ent);
  42. void consensus_cache_entry_mark_for_removal(consensus_cache_entry_t *ent);
  43. void consensus_cache_entry_mark_for_aggressive_release(
  44. consensus_cache_entry_t *ent);
  45. int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent,
  46. const uint8_t **body_out,
  47. size_t *sz_out);
  48. #ifdef TOR_UNIT_TESTS
  49. int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent);
  50. #endif
  51. #endif /* !defined(TOR_CONSCACHE_H) */