conscache.h 2.3 KB

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