diff options
author | Florian Dold <florian.dold@gmail.com> | 2015-10-05 21:26:56 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2015-10-05 21:26:56 +0000 |
commit | a11e17158609766f29c40de6daecf5ce02b38e6c (patch) | |
tree | 1fbce1a057d5e74415781074a429d53751b43111 /src/set/set_api.c | |
parent | 4dcb414e2faabc800577c25dec3b63e3ceaaa84b (diff) | |
download | gnunet-a11e17158609766f29c40de6daecf5ce02b38e6c.tar.gz gnunet-a11e17158609766f29c40de6daecf5ce02b38e6c.zip |
work on consensus and set
- evil peers for consensus
- various fixes for consensus and set
Diffstat (limited to 'src/set/set_api.c')
-rw-r--r-- | src/set/set_api.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/set/set_api.c b/src/set/set_api.c index 16aa87cd0..6cbee9a57 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c | |||
@@ -1112,4 +1112,40 @@ GNUNET_SET_copy_lazy (struct GNUNET_SET_Handle *set, | |||
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | 1114 | ||
1115 | /** | ||
1116 | * Create a copy of an element. The copy | ||
1117 | * must be GNUNET_free-d by the caller. | ||
1118 | * | ||
1119 | * @param element the element to copy | ||
1120 | * @return the copied element | ||
1121 | */ | ||
1122 | struct GNUNET_SET_Element * | ||
1123 | GNUNET_SET_element_dup (const struct GNUNET_SET_Element *element) | ||
1124 | { | ||
1125 | struct GNUNET_SET_Element *copy; | ||
1126 | |||
1127 | copy = GNUNET_malloc (element->size + sizeof (struct GNUNET_SET_Element)); | ||
1128 | copy->size = element->size; | ||
1129 | copy->element_type = element->element_type; | ||
1130 | copy->data = ©[1]; | ||
1131 | memcpy ((void *) copy->data, element->data, copy->size); | ||
1132 | |||
1133 | return copy; | ||
1134 | } | ||
1135 | |||
1136 | |||
1137 | /** | ||
1138 | * Hash a set element. | ||
1139 | * | ||
1140 | * @param element the element that should be hashed | ||
1141 | * @param ret_hash a pointer to where the hash of @a element | ||
1142 | * should be stored | ||
1143 | */ | ||
1144 | void | ||
1145 | GNUNET_SET_element_hash (const struct GNUNET_SET_Element *element, struct GNUNET_HashCode *ret_hash) | ||
1146 | { | ||
1147 | /* FIXME: The element type should also be hashed. */ | ||
1148 | GNUNET_CRYPTO_hash (element->data, element->size, ret_hash); | ||
1149 | } | ||
1150 | |||
1115 | /* end of set_api.c */ | 1151 | /* end of set_api.c */ |