diff options
Diffstat (limited to 'src/consensus/ibf.h')
-rw-r--r-- | src/consensus/ibf.h | 53 |
1 files changed, 8 insertions, 45 deletions
diff --git a/src/consensus/ibf.h b/src/consensus/ibf.h index 609653889..2bf3ef7c7 100644 --- a/src/consensus/ibf.h +++ b/src/consensus/ibf.h | |||
@@ -81,11 +81,6 @@ struct InvertibleBloomFilter | |||
81 | uint8_t hash_num; | 81 | uint8_t hash_num; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Salt for mingling hashes | ||
85 | */ | ||
86 | uint32_t salt; | ||
87 | |||
88 | /** | ||
89 | * Xor sums of the elements' keys, used to identify the elements. | 84 | * Xor sums of the elements' keys, used to identify the elements. |
90 | * Array of 'size' elements. | 85 | * Array of 'size' elements. |
91 | */ | 86 | */ |
@@ -107,58 +102,28 @@ struct InvertibleBloomFilter | |||
107 | 102 | ||
108 | 103 | ||
109 | /** | 104 | /** |
110 | * Write an ibf. | 105 | * Write buckets from an ibf to a buffer. |
106 | * Exactly (IBF_BUCKET_SIZE*ibf->size) bytes are written to buf. | ||
111 | * | 107 | * |
112 | * @param ibf the ibf to write | 108 | * @param ibf the ibf to write |
113 | * @param start with which bucket to start | 109 | * @param start with which bucket to start |
114 | * @param count how many buckets to write | 110 | * @param count how many buckets to write |
115 | * @param buf buffer to write the data to, will be updated to point to the | 111 | * @param buf buffer to write the data to |
116 | * first byte after the written data | ||
117 | * @param size pointer to the size of the buffer, will be updated, can be NULL | ||
118 | */ | 112 | */ |
119 | void | 113 | void |
120 | ibf_write_slice (const struct InvertibleBloomFilter *ibf, uint32_t start, uint32_t count, void **buf, size_t *size); | 114 | ibf_write_slice (const struct InvertibleBloomFilter *ibf, uint32_t start, uint32_t count, void *buf); |
121 | 115 | ||
122 | 116 | ||
123 | /** | 117 | /** |
124 | * Read an ibf. | 118 | * Read buckets from a buffer into an ibf. |
125 | * | 119 | * |
126 | * @param buf pointer to the buffer to write to, will point to first | 120 | * @param buf pointer to the buffer to read from |
127 | * byte after the written data | ||
128 | * @param size size of the buffer, will be updated | ||
129 | * @param start which bucket to start at | 121 | * @param start which bucket to start at |
130 | * @param count how many buckets to read | 122 | * @param count how many buckets to read |
131 | * @param ibf the ibf to read from | 123 | * @param ibf the ibf to read from |
132 | * @return GNUNET_OK on success | ||
133 | */ | ||
134 | int | ||
135 | ibf_read_slice (void **buf, size_t *size, uint32_t start, uint32_t count, struct InvertibleBloomFilter *dst); | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Write an ibf. | ||
140 | * | ||
141 | * @param ibf the ibf to write | ||
142 | * @param buf buffer to write the data to, will be updated to point to the | ||
143 | * first byte after the written data | ||
144 | * @param size pointer to the size of the buffer, will be updated, can be NULL | ||
145 | */ | 124 | */ |
146 | void | 125 | void |
147 | ibf_write (const struct InvertibleBloomFilter *ibf, void **buf, size_t *size); | 126 | ibf_read_slice (const void *buf, uint32_t start, uint32_t count, struct InvertibleBloomFilter *ibf); |
148 | |||
149 | |||
150 | |||
151 | /** | ||
152 | * Read an ibf. | ||
153 | * | ||
154 | * @param buf pointer to the buffer to write to, will point to first | ||
155 | * byte after the written data | ||
156 | * @param size size of the buffer, will be updated | ||
157 | * @param dst ibf to write buckets to | ||
158 | * @return GNUNET_OK on success | ||
159 | */ | ||
160 | int | ||
161 | ibf_read (void **buf, size_t *size, struct InvertibleBloomFilter *dst); | ||
162 | 127 | ||
163 | 128 | ||
164 | /** | 129 | /** |
@@ -187,12 +152,10 @@ ibf_hashcode_from_key (struct IBF_Key key, struct GNUNET_HashCode *dst); | |||
187 | * | 152 | * |
188 | * @param size number of IBF buckets | 153 | * @param size number of IBF buckets |
189 | * @param hash_num number of buckets one element is hashed in, usually 3 or 4 | 154 | * @param hash_num number of buckets one element is hashed in, usually 3 or 4 |
190 | * @param salt salt for mingling hashes, different salt may | ||
191 | * result in less (or more) collisions | ||
192 | * @return the newly created invertible bloom filter | 155 | * @return the newly created invertible bloom filter |
193 | */ | 156 | */ |
194 | struct InvertibleBloomFilter * | 157 | struct InvertibleBloomFilter * |
195 | ibf_create (uint32_t size, uint8_t hash_num, uint32_t salt); | 158 | ibf_create (uint32_t size, uint8_t hash_num); |
196 | 159 | ||
197 | 160 | ||
198 | /** | 161 | /** |