conscache.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. consensus_cache_entry_t *consensus_cache_add(consensus_cache_t *cache,
  18. const config_line_t *labels,
  19. const uint8_t *data,
  20. size_t datalen);
  21. consensus_cache_entry_t *consensus_cache_find_first(
  22. consensus_cache_t *cache,
  23. const char *key,
  24. const char *value);
  25. void consensus_cache_find_all(smartlist_t *out,
  26. consensus_cache_t *cache,
  27. const char *key,
  28. const char *value);
  29. void consensus_cache_filter_list(smartlist_t *lst,
  30. const char *key,
  31. const char *value);
  32. const char *consensus_cache_entry_get_value(const consensus_cache_entry_t *ent,
  33. const char *key);
  34. const config_line_t *consensus_cache_entry_get_labels(
  35. const consensus_cache_entry_t *ent);
  36. void consensus_cache_entry_incref(consensus_cache_entry_t *ent);
  37. void consensus_cache_entry_decref(consensus_cache_entry_t *ent);
  38. void consensus_cache_entry_mark_for_removal(consensus_cache_entry_t *ent);
  39. void consensus_cache_entry_mark_for_aggressive_release(
  40. consensus_cache_entry_t *ent);
  41. int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent,
  42. const uint8_t **body_out,
  43. size_t *sz_out);
  44. #ifdef TOR_UNIT_TESTS
  45. int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent);
  46. #endif
  47. #endif