+ case GNUNET_SET_STATUS_OK:
+ if (sizeof (struct Target) != element->size)
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+ target = GNUNET_new (struct Target);
+ memcpy (target, element->data, sizeof (struct Target));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received information about peer `%s' with distance %u\n",
+ GNUNET_i2s (&target->peer), ntohl(target->distance));
+ if (NULL == neighbor->neighbor_table_consensus)
+ neighbor->neighbor_table_consensus = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
+ if (GNUNET_YES !=
+ GNUNET_CONTAINER_multipeermap_put (neighbor->neighbor_table_consensus,
+ &target->peer,
+ target,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (target);
+ }
+ break;
+ case GNUNET_SET_STATUS_TIMEOUT:
+ case GNUNET_SET_STATUS_FAILURE:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Failed to establish DV union, will try again later\n");
+ neighbor->set_op = NULL;
+ if (NULL != neighbor->neighbor_table_consensus)
+ {
+ GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table_consensus,
+ &free_targets,
+ NULL);
+ GNUNET_CONTAINER_multipeermap_destroy (neighbor->neighbor_table_consensus);
+ neighbor->neighbor_table_consensus = NULL;
+ }
+ if (0 < memcmp (&neighbor->peer,
+ &my_identity,
+ sizeof (struct GNUNET_PeerIdentity)))
+ neighbor->initiate_task = GNUNET_SCHEDULER_add_delayed (GNUNET_DV_CONSENSUS_FREQUENCY,
+ &initiate_set_union,
+ neighbor);
+ break;
+ case GNUNET_SET_STATUS_HALF_DONE:
+ break;
+ case GNUNET_SET_STATUS_DONE:
+ /* we got all of our updates; integrate routing table! */
+ neighbor->target_removed = GNUNET_NO;
+ if (NULL == neighbor->neighbor_table_consensus)
+ neighbor->neighbor_table_consensus = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
+ if (NULL != neighbor->neighbor_table)
+ GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table,
+ &check_target_removed,
+ neighbor);
+ if (GNUNET_YES == neighbor->target_removed)
+ {
+ /* check if we got an alternative for the removed routes */
+ GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors,
+ &refresh_routes,
+ NULL);
+ }
+ /* add targets that appeared (and check for improved routes) */
+ GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table_consensus,
+ &check_target_added,
+ neighbor);
+ if (NULL != neighbor->neighbor_table)
+ {
+ GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table,
+ &free_targets,
+ NULL);
+ GNUNET_CONTAINER_multipeermap_destroy (neighbor->neighbor_table);
+ neighbor->neighbor_table = NULL;
+ }
+ neighbor->neighbor_table = neighbor->neighbor_table_consensus;
+ neighbor->neighbor_table_consensus = NULL;
+
+ /* operation done, schedule next run! */
+ neighbor->set_op = NULL;
+ if (0 < memcmp (&neighbor->peer,
+ &my_identity,
+ sizeof (struct GNUNET_PeerIdentity)))
+ neighbor->initiate_task = GNUNET_SCHEDULER_add_delayed (GNUNET_DV_CONSENSUS_FREQUENCY,
+ &initiate_set_union,
+ neighbor);
+ break;
+ default:
+ GNUNET_break (0);
+ return;