aboutsummaryrefslogtreecommitdiff
path: root/src/set/ibf.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/set/ibf.h')
-rw-r--r--src/set/ibf.h60
1 files changed, 28 insertions, 32 deletions
diff --git a/src/set/ibf.h b/src/set/ibf.h
index dd0edc053..94079a39f 100644
--- a/src/set/ibf.h
+++ b/src/set/ibf.h
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file set/ibf.h 22 * @file set/ibf.h
@@ -42,8 +42,7 @@ extern "C"
42/** 42/**
43 * Keys that can be inserted into and removed from an IBF. 43 * Keys that can be inserted into and removed from an IBF.
44 */ 44 */
45struct IBF_Key 45struct IBF_Key {
46{
47 uint64_t key_val; 46 uint64_t key_val;
48}; 47};
49 48
@@ -51,8 +50,7 @@ struct IBF_Key
51/** 50/**
52 * Hash of an IBF key. 51 * Hash of an IBF key.
53 */ 52 */
54struct IBF_KeyHash 53struct IBF_KeyHash {
55{
56 uint32_t key_hash_val; 54 uint32_t key_hash_val;
57}; 55};
58 56
@@ -60,8 +58,7 @@ struct IBF_KeyHash
60/** 58/**
61 * Type of the count field of IBF buckets. 59 * Type of the count field of IBF buckets.
62 */ 60 */
63struct IBF_Count 61struct IBF_Count {
64{
65 int8_t count_val; 62 int8_t count_val;
66}; 63};
67 64
@@ -69,8 +66,8 @@ struct IBF_Count
69/** 66/**
70 * Size of one ibf bucket in bytes 67 * Size of one ibf bucket in bytes
71 */ 68 */
72#define IBF_BUCKET_SIZE (sizeof (struct IBF_Count) + sizeof (struct IBF_Key) + \ 69#define IBF_BUCKET_SIZE (sizeof(struct IBF_Count) + sizeof(struct IBF_Key) + \
73 sizeof (struct IBF_KeyHash)) 70 sizeof(struct IBF_KeyHash))
74 71
75 72
76/** 73/**
@@ -79,8 +76,7 @@ struct IBF_Count
79 * An IBF is a counting bloom filter that has the ability to restore 76 * An IBF is a counting bloom filter that has the ability to restore
80 * the hashes of its stored elements with high probability. 77 * the hashes of its stored elements with high probability.
81 */ 78 */
82struct InvertibleBloomFilter 79struct InvertibleBloomFilter {
83{
84 /** 80 /**
85 * How many cells does this IBF have? 81 * How many cells does this IBF have?
86 */ 82 */
@@ -123,10 +119,10 @@ struct InvertibleBloomFilter
123 * @param buf buffer to write the data to 119 * @param buf buffer to write the data to
124 */ 120 */
125void 121void
126ibf_write_slice (const struct InvertibleBloomFilter *ibf, 122ibf_write_slice(const struct InvertibleBloomFilter *ibf,
127 uint32_t start, 123 uint32_t start,
128 uint32_t count, 124 uint32_t count,
129 void *buf); 125 void *buf);
130 126
131 127
132/** 128/**
@@ -138,10 +134,10 @@ ibf_write_slice (const struct InvertibleBloomFilter *ibf,
138 * @param ibf the ibf to write to 134 * @param ibf the ibf to write to
139 */ 135 */
140void 136void
141ibf_read_slice (const void *buf, 137ibf_read_slice(const void *buf,
142 uint32_t start, 138 uint32_t start,
143 uint32_t count, 139 uint32_t count,
144 struct InvertibleBloomFilter *ibf); 140 struct InvertibleBloomFilter *ibf);
145 141
146 142
147/** 143/**
@@ -151,7 +147,7 @@ ibf_read_slice (const void *buf,
151 * @return a key 147 * @return a key
152 */ 148 */
153struct IBF_Key 149struct IBF_Key
154ibf_key_from_hashcode (const struct GNUNET_HashCode *hash); 150ibf_key_from_hashcode(const struct GNUNET_HashCode *hash);
155 151
156 152
157/** 153/**
@@ -162,7 +158,7 @@ ibf_key_from_hashcode (const struct GNUNET_HashCode *hash);
162 * @param dst hashcode to store the result in 158 * @param dst hashcode to store the result in
163 */ 159 */
164void 160void
165ibf_hashcode_from_key (struct IBF_Key key, struct GNUNET_HashCode *dst); 161ibf_hashcode_from_key(struct IBF_Key key, struct GNUNET_HashCode *dst);
166 162
167 163
168/** 164/**
@@ -173,7 +169,7 @@ ibf_hashcode_from_key (struct IBF_Key key, struct GNUNET_HashCode *dst);
173 * @return the newly created invertible bloom filter, NULL on error 169 * @return the newly created invertible bloom filter, NULL on error
174 */ 170 */
175struct InvertibleBloomFilter * 171struct InvertibleBloomFilter *
176ibf_create (uint32_t size, uint8_t hash_num); 172ibf_create(uint32_t size, uint8_t hash_num);
177 173
178 174
179/** 175/**
@@ -183,7 +179,7 @@ ibf_create (uint32_t size, uint8_t hash_num);
183 * @param key the element's hash code 179 * @param key the element's hash code
184 */ 180 */
185void 181void
186ibf_insert (struct InvertibleBloomFilter *ibf, struct IBF_Key key); 182ibf_insert(struct InvertibleBloomFilter *ibf, struct IBF_Key key);
187 183
188 184
189/** 185/**
@@ -193,7 +189,7 @@ ibf_insert (struct InvertibleBloomFilter *ibf, struct IBF_Key key);
193 * @param key the element's hash code 189 * @param key the element's hash code
194 */ 190 */
195void 191void
196ibf_remove (struct InvertibleBloomFilter *ibf, struct IBF_Key key); 192ibf_remove(struct InvertibleBloomFilter *ibf, struct IBF_Key key);
197 193
198 194
199/** 195/**
@@ -204,8 +200,8 @@ ibf_remove (struct InvertibleBloomFilter *ibf, struct IBF_Key key);
204 * @param ibf2 IBF that will be subtracted from ibf1 200 * @param ibf2 IBF that will be subtracted from ibf1
205 */ 201 */
206void 202void
207ibf_subtract (struct InvertibleBloomFilter *ibf1, 203ibf_subtract(struct InvertibleBloomFilter *ibf1,
208 const struct InvertibleBloomFilter *ibf2); 204 const struct InvertibleBloomFilter *ibf2);
209 205
210 206
211/** 207/**
@@ -221,9 +217,9 @@ ibf_subtract (struct InvertibleBloomFilter *ibf1,
221 * #GNUNET_SYSERR if the decoding has failed 217 * #GNUNET_SYSERR if the decoding has failed
222 */ 218 */
223int 219int
224ibf_decode (struct InvertibleBloomFilter *ibf, 220ibf_decode(struct InvertibleBloomFilter *ibf,
225 int *ret_side, 221 int *ret_side,
226 struct IBF_Key *ret_id); 222 struct IBF_Key *ret_id);
227 223
228 224
229/** 225/**
@@ -232,7 +228,7 @@ ibf_decode (struct InvertibleBloomFilter *ibf,
232 * @param ibf the IBF to copy 228 * @param ibf the IBF to copy
233 */ 229 */
234struct InvertibleBloomFilter * 230struct InvertibleBloomFilter *
235ibf_dup (const struct InvertibleBloomFilter *ibf); 231ibf_dup(const struct InvertibleBloomFilter *ibf);
236 232
237 233
238/** 234/**
@@ -242,7 +238,7 @@ ibf_dup (const struct InvertibleBloomFilter *ibf);
242 * @param ibf the intertible bloom filter to destroy 238 * @param ibf the intertible bloom filter to destroy
243 */ 239 */
244void 240void
245ibf_destroy (struct InvertibleBloomFilter *ibf); 241ibf_destroy(struct InvertibleBloomFilter *ibf);
246 242
247 243
248#if 0 /* keep Emacsens' auto-indent happy */ 244#if 0 /* keep Emacsens' auto-indent happy */