From 025610612d78fe0a0ec95dd88c3d44e4bf643603 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 29 Mar 2016 15:08:04 -0400 Subject: prop224: Directory cache support This implements the proposal 224 directory descriptor cache store and lookup functionalities. Furthermore, it merges the OOM call for the HSDir cache with current protocol v2 and the new upcoming v3. Add hs_cache.{c|h} with store/lookup API. Closes #18572 Signed-off-by: David Goulet Signed-off-by: George Kadianakis --- src/or/hs_descriptor.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/or/hs_descriptor.c') diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c index cdbea76605..9714d52f8c 100644 --- a/src/or/hs_descriptor.c +++ b/src/or/hs_descriptor.c @@ -1918,3 +1918,15 @@ hs_descriptor_free(hs_descriptor_t *desc) desc_encrypted_data_free_contents(&desc->encrypted_data); tor_free(desc); } + +/* Return the size in bytes of the given plaintext data object. A sizeof() is + * not enough because the object contains pointers and the encrypted blob. + * This is particularly useful for our OOM subsystem that tracks the HSDir + * cache size for instance. */ +size_t +hs_desc_plaintext_obj_size(const hs_desc_plaintext_data_t *data) +{ + tor_assert(data); + return (sizeof(*data) + sizeof(*data->signing_key_cert) + + data->encrypted_blob_size); +} -- cgit v1.2.3-54-g00ecf