diff options
Diffstat (limited to 'src/setu/ibf.h')
-rw-r--r-- | src/setu/ibf.h | 65 |
1 files changed, 60 insertions, 5 deletions
diff --git a/src/setu/ibf.h b/src/setu/ibf.h index 7c2ab33b1..5628405dc 100644 --- a/src/setu/ibf.h +++ b/src/setu/ibf.h | |||
@@ -22,6 +22,7 @@ | |||
22 | * @file set/ibf.h | 22 | * @file set/ibf.h |
23 | * @brief invertible bloom filter | 23 | * @brief invertible bloom filter |
24 | * @author Florian Dold | 24 | * @author Florian Dold |
25 | * @author Elias Summermatter | ||
25 | */ | 26 | */ |
26 | 27 | ||
27 | #ifndef GNUNET_CONSENSUS_IBF_H | 28 | #ifndef GNUNET_CONSENSUS_IBF_H |
@@ -62,7 +63,7 @@ struct IBF_KeyHash | |||
62 | */ | 63 | */ |
63 | struct IBF_Count | 64 | struct IBF_Count |
64 | { | 65 | { |
65 | int8_t count_val; | 66 | int64_t count_val; |
66 | }; | 67 | }; |
67 | 68 | ||
68 | 69 | ||
@@ -93,6 +94,20 @@ struct InvertibleBloomFilter | |||
93 | uint8_t hash_num; | 94 | uint8_t hash_num; |
94 | 95 | ||
95 | /** | 96 | /** |
97 | * If an IBF is decoded this count stores how many | ||
98 | * elements are on the local site. This is used | ||
99 | * to estimate the set difference on a site | ||
100 | */ | ||
101 | int local_decoded_count; | ||
102 | |||
103 | /** | ||
104 | * If an IBF is decoded this count stores how many | ||
105 | * elements are on the remote site. This is used | ||
106 | * to estimate the set difference on a site | ||
107 | */ | ||
108 | int remote_decoded_count; | ||
109 | |||
110 | /** | ||
96 | * Xor sums of the elements' keys, used to identify the elements. | 111 | * Xor sums of the elements' keys, used to identify the elements. |
97 | * Array of 'size' elements. | 112 | * Array of 'size' elements. |
98 | */ | 113 | */ |
@@ -125,8 +140,9 @@ struct InvertibleBloomFilter | |||
125 | void | 140 | void |
126 | ibf_write_slice (const struct InvertibleBloomFilter *ibf, | 141 | ibf_write_slice (const struct InvertibleBloomFilter *ibf, |
127 | uint32_t start, | 142 | uint32_t start, |
128 | uint32_t count, | 143 | uint64_t count, |
129 | void *buf); | 144 | void *buf, |
145 | uint8_t counter_max_length); | ||
130 | 146 | ||
131 | 147 | ||
132 | /** | 148 | /** |
@@ -140,8 +156,9 @@ ibf_write_slice (const struct InvertibleBloomFilter *ibf, | |||
140 | void | 156 | void |
141 | ibf_read_slice (const void *buf, | 157 | ibf_read_slice (const void *buf, |
142 | uint32_t start, | 158 | uint32_t start, |
143 | uint32_t count, | 159 | uint64_t count, |
144 | struct InvertibleBloomFilter *ibf); | 160 | struct InvertibleBloomFilter *ibf, |
161 | uint8_t counter_max_length); | ||
145 | 162 | ||
146 | 163 | ||
147 | /** | 164 | /** |
@@ -244,6 +261,44 @@ ibf_dup (const struct InvertibleBloomFilter *ibf); | |||
244 | void | 261 | void |
245 | ibf_destroy (struct InvertibleBloomFilter *ibf); | 262 | ibf_destroy (struct InvertibleBloomFilter *ibf); |
246 | 263 | ||
264 | uint8_t | ||
265 | ibf_get_max_counter (struct InvertibleBloomFilter *ibf); | ||
266 | |||
267 | |||
268 | /** | ||
269 | * Packs the counter to transmit only the smallest possible amount of bytes and | ||
270 | * preventing overflow of the counter | ||
271 | * @param ibf the ibf to write | ||
272 | * @param start with which bucket to start | ||
273 | * @param count how many buckets to write | ||
274 | * @param buf buffer to write the data to | ||
275 | * @param max bit length of a counter for unpacking | ||
276 | */ | ||
277 | |||
278 | void | ||
279 | pack_counter (const struct InvertibleBloomFilter *ibf, | ||
280 | uint32_t start, | ||
281 | uint64_t count, | ||
282 | uint8_t *buf, | ||
283 | uint8_t counter_max_length); | ||
284 | |||
285 | /** | ||
286 | * Unpacks the counter to transmit only the smallest possible amount of bytes and | ||
287 | * preventing overflow of the counter | ||
288 | * @param ibf the ibf to write | ||
289 | * @param start with which bucket to start | ||
290 | * @param count how many buckets to write | ||
291 | * @param buf buffer to write the data to | ||
292 | * @param max bit length of a counter for unpacking | ||
293 | */ | ||
294 | |||
295 | void | ||
296 | unpack_counter (const struct InvertibleBloomFilter *ibf, | ||
297 | uint32_t start, | ||
298 | uint64_t count, | ||
299 | uint8_t *buf, | ||
300 | uint8_t counter_max_length); | ||
301 | |||
247 | 302 | ||
248 | #if 0 /* keep Emacsens' auto-indent happy */ | 303 | #if 0 /* keep Emacsens' auto-indent happy */ |
249 | { | 304 | { |