minor updates on upcoming changelog
[tor.git] / src / or / consdiffmgr.h
blobdf569c8e235f89e3ecd483595c07106920d1094f
1 /* Copyright (c) 2017, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #ifndef TOR_CONSDIFFMGR_H
5 #define TOR_CONSDIFFMGR_H
7 /**
8 * Possible outcomes from trying to look up a given consensus diff.
9 */
10 typedef enum consdiff_status_t {
11 CONSDIFF_AVAILABLE,
12 CONSDIFF_NOT_FOUND,
13 CONSDIFF_IN_PROGRESS,
14 } consdiff_status_t;
16 typedef struct consdiff_cfg_t {
17 int32_t cache_max_num;
18 } consdiff_cfg_t;
20 struct consensus_cache_entry_t; // from conscache.h
22 int consdiffmgr_add_consensus(const char *consensus,
23 const networkstatus_t *as_parsed);
25 consdiff_status_t consdiffmgr_find_consensus(
26 struct consensus_cache_entry_t **entry_out,
27 consensus_flavor_t flavor,
28 compress_method_t method);
30 consdiff_status_t consdiffmgr_find_diff_from(
31 struct consensus_cache_entry_t **entry_out,
32 consensus_flavor_t flavor,
33 int digest_type,
34 const uint8_t *digest,
35 size_t digestlen,
36 compress_method_t method);
38 int consensus_cache_entry_get_voter_id_digests(
39 const struct consensus_cache_entry_t *ent,
40 smartlist_t *out);
41 int consensus_cache_entry_get_fresh_until(
42 const struct consensus_cache_entry_t *ent,
43 time_t *out);
44 int consensus_cache_entry_get_valid_until(
45 const struct consensus_cache_entry_t *ent,
46 time_t *out);
47 int consensus_cache_entry_get_valid_after(
48 const struct consensus_cache_entry_t *ent,
49 time_t *out);
51 void consdiffmgr_rescan(void);
52 int consdiffmgr_cleanup(void);
53 void consdiffmgr_enable_background_compression(void);
54 void consdiffmgr_configure(const consdiff_cfg_t *cfg);
55 struct sandbox_cfg_elem;
56 int consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem **cfg);
57 void consdiffmgr_free_all(void);
58 int consdiffmgr_validate(void);
60 #ifdef CONSDIFFMGR_PRIVATE
61 STATIC unsigned n_diff_compression_methods(void);
62 STATIC unsigned n_consensus_compression_methods(void);
63 STATIC consensus_cache_t *cdm_cache_get(void);
64 STATIC consensus_cache_entry_t *cdm_cache_lookup_consensus(
65 consensus_flavor_t flavor, time_t valid_after);
66 STATIC int cdm_entry_get_sha3_value(uint8_t *digest_out,
67 consensus_cache_entry_t *ent,
68 const char *label);
69 STATIC int uncompress_or_copy(char **out, size_t *outlen,
70 consensus_cache_entry_t *ent);
71 #endif /* defined(CONSDIFFMGR_PRIVATE) */
73 #endif /* !defined(TOR_CONSDIFFMGR_H) */