conscache.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. typedef struct consensus_cache_entry_t consensus_cache_entry_t;
  6. typedef struct consensus_cache_t consensus_cache_t;
  7. consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
  8. void consensus_cache_free(consensus_cache_t *cache);
  9. void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
  10. void consensus_cache_delete_pending(consensus_cache_t *cache);
  11. consensus_cache_entry_t *consensus_cache_add(consensus_cache_t *cache,
  12. const config_line_t *labels,
  13. const uint8_t *data,
  14. size_t datalen);
  15. consensus_cache_entry_t *consensus_cache_find_first(
  16. consensus_cache_t *cache,
  17. const char *key,
  18. const char *value);
  19. void consensus_cache_find_all(smartlist_t *out,
  20. consensus_cache_t *cache,
  21. const char *key,
  22. const char *value);
  23. void consensus_cache_filter_list(smartlist_t *lst,
  24. const char *key,
  25. const char *value);
  26. const char *consensus_cache_entry_get_value(const consensus_cache_entry_t *ent,
  27. const char *key);
  28. const config_line_t *consensus_cache_entry_get_labels(
  29. const consensus_cache_entry_t *ent);
  30. void consensus_cache_entry_incref(consensus_cache_entry_t *ent);
  31. void consensus_cache_entry_decref(consensus_cache_entry_t *ent);
  32. void consensus_cache_entry_mark_for_removal(consensus_cache_entry_t *ent);
  33. void consensus_cache_entry_mark_for_aggressive_release(
  34. consensus_cache_entry_t *ent);
  35. int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent,
  36. const uint8_t **body_out,
  37. size_t *sz_out);
  38. #ifdef TOR_UNIT_TESTS
  39. int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent);
  40. #endif
  41. #endif