2018-06-20 08:13:28 -04:00
|
|
|
/* Copyright (c) 2017-2018, The Tor Project, Inc. */
|
2017-04-04 09:35:39 -04:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
#ifndef TOR_CONSCACHE_H
|
|
|
|
#define TOR_CONSCACHE_H
|
|
|
|
|
2018-06-20 09:35:05 -04:00
|
|
|
#include "common/handles.h"
|
2017-04-11 15:47:21 -04:00
|
|
|
|
2017-04-04 09:35:39 -04:00
|
|
|
typedef struct consensus_cache_entry_t consensus_cache_entry_t;
|
|
|
|
typedef struct consensus_cache_t consensus_cache_t;
|
|
|
|
|
2017-04-11 15:47:21 -04:00
|
|
|
HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, )
|
2017-11-17 12:27:25 -05:00
|
|
|
#define consensus_cache_entry_handle_free(h) \
|
2017-12-07 10:52:55 -05:00
|
|
|
FREE_AND_NULL(consensus_cache_entry_handle_t, \
|
|
|
|
consensus_cache_entry_handle_free_, (h))
|
2017-04-11 15:47:21 -04:00
|
|
|
|
2017-04-04 09:35:39 -04:00
|
|
|
consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
|
2017-11-21 09:37:47 -05:00
|
|
|
void consensus_cache_free_(consensus_cache_t *cache);
|
2017-12-07 10:52:55 -05:00
|
|
|
#define consensus_cache_free(cache) \
|
|
|
|
FREE_AND_NULL(consensus_cache_t, consensus_cache_free_, (cache))
|
2017-04-25 19:52:34 -04:00
|
|
|
struct sandbox_cfg_elem;
|
2017-08-29 13:03:36 -04:00
|
|
|
int consensus_cache_may_overallocate(consensus_cache_t *cache);
|
2017-04-25 19:52:34 -04:00
|
|
|
int consensus_cache_register_with_sandbox(consensus_cache_t *cache,
|
|
|
|
struct sandbox_cfg_elem **cfg);
|
2017-04-04 09:35:39 -04:00
|
|
|
void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
|
2017-04-26 10:13:25 -04:00
|
|
|
void consensus_cache_delete_pending(consensus_cache_t *cache,
|
|
|
|
int force);
|
2017-04-26 10:42:11 -04:00
|
|
|
int consensus_cache_get_n_filenames_available(consensus_cache_t *cache);
|
2017-04-04 09:35:39 -04:00
|
|
|
consensus_cache_entry_t *consensus_cache_add(consensus_cache_t *cache,
|
|
|
|
const config_line_t *labels,
|
|
|
|
const uint8_t *data,
|
|
|
|
size_t datalen);
|
|
|
|
|
|
|
|
consensus_cache_entry_t *consensus_cache_find_first(
|
|
|
|
consensus_cache_t *cache,
|
|
|
|
const char *key,
|
|
|
|
const char *value);
|
|
|
|
|
|
|
|
void consensus_cache_find_all(smartlist_t *out,
|
|
|
|
consensus_cache_t *cache,
|
|
|
|
const char *key,
|
|
|
|
const char *value);
|
|
|
|
void consensus_cache_filter_list(smartlist_t *lst,
|
|
|
|
const char *key,
|
|
|
|
const char *value);
|
|
|
|
|
|
|
|
const char *consensus_cache_entry_get_value(const consensus_cache_entry_t *ent,
|
|
|
|
const char *key);
|
|
|
|
const config_line_t *consensus_cache_entry_get_labels(
|
|
|
|
const consensus_cache_entry_t *ent);
|
|
|
|
|
|
|
|
void consensus_cache_entry_incref(consensus_cache_entry_t *ent);
|
|
|
|
void consensus_cache_entry_decref(consensus_cache_entry_t *ent);
|
|
|
|
|
|
|
|
void consensus_cache_entry_mark_for_removal(consensus_cache_entry_t *ent);
|
|
|
|
void consensus_cache_entry_mark_for_aggressive_release(
|
|
|
|
consensus_cache_entry_t *ent);
|
|
|
|
int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent,
|
|
|
|
const uint8_t **body_out,
|
|
|
|
size_t *sz_out);
|
|
|
|
|
2017-04-04 13:51:34 -04:00
|
|
|
#ifdef TOR_UNIT_TESTS
|
|
|
|
int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent);
|
|
|
|
#endif
|
|
|
|
|
2017-09-15 16:24:44 -04:00
|
|
|
#endif /* !defined(TOR_CONSCACHE_H) */
|
2017-04-04 09:35:39 -04:00
|
|
|
|