aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-10-05 21:26:56 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-10-05 21:26:56 +0000
commita11e17158609766f29c40de6daecf5ce02b38e6c (patch)
tree1fbce1a057d5e74415781074a429d53751b43111 /src/set
parent4dcb414e2faabc800577c25dec3b63e3ceaaa84b (diff)
downloadgnunet-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')
-rw-r--r--src/set/gnunet-service-set.c10
-rw-r--r--src/set/set_api.c36
2 files changed, 41 insertions, 5 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 2f1578514..986f52982 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -844,6 +844,11 @@ execute_add (struct Set *set,
844 ee->mutations = NULL; 844 ee->mutations = NULL;
845 ee->mutations_size = 0; 845 ee->mutations_size = 0;
846 ee->element_hash = hash; 846 ee->element_hash = hash;
847 GNUNET_break (GNUNET_YES ==
848 GNUNET_CONTAINER_multihashmap_put (set->content->elements,
849 &ee->element_hash,
850 ee,
851 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
847 } 852 }
848 else if (GNUNET_YES == _GSS_is_element_of_set (ee, set)) 853 else if (GNUNET_YES == _GSS_is_element_of_set (ee, set))
849 { 854 {
@@ -859,11 +864,6 @@ execute_add (struct Set *set,
859 GNUNET_array_append (ee->mutations, ee->mutations_size, mut); 864 GNUNET_array_append (ee->mutations, ee->mutations_size, mut);
860 } 865 }
861 866
862 GNUNET_break (GNUNET_YES ==
863 GNUNET_CONTAINER_multihashmap_put (set->content->elements,
864 &ee->element_hash,
865 ee,
866 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
867 set->vt->add (set->state, ee); 867 set->vt->add (set->state, ee);
868} 868}
869 869
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 */
1122struct GNUNET_SET_Element *
1123GNUNET_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 = &copy[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 */
1144void
1145GNUNET_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 */