diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-04-04 09:35:39 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-06 11:48:41 -0400 |
commit | 4404dc5756c929fccc5784a637014aee929bdfd1 (patch) | |
tree | 43c7036ba8145d4d670dcdad5e1119ec5f659160 /src/or/conscache.h | |
parent | 5f8860a16f61cd5bbba01fd268071aa8e6b7ba8c (diff) | |
download | tor-4404dc5756c929fccc5784a637014aee929bdfd1.tar.gz tor-4404dc5756c929fccc5784a637014aee929bdfd1.zip |
Add a 'consensus cache' type on top of storagedir.
Every file in the cache is labeled. The labels are held in memory;
the bodies are mapped on demand.
Diffstat (limited to 'src/or/conscache.h')
-rw-r--r-- | src/or/conscache.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/or/conscache.h b/src/or/conscache.h new file mode 100644 index 0000000000..0a0fc61071 --- /dev/null +++ b/src/or/conscache.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2017, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +#ifndef TOR_CONSCACHE_H +#define TOR_CONSCACHE_H + +typedef struct consensus_cache_entry_t consensus_cache_entry_t; +typedef struct consensus_cache_t consensus_cache_t; + +consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries); +void consensus_cache_free(consensus_cache_t *cache); +void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff); +void consensus_cache_delete_pending(consensus_cache_t *cache); +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); + +#endif + |