conscache.h 2.7 KB

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