+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received BF in phase %u, foreign count is %u, my element count is %u/%u\n",
+ op->state->phase,
+ op->remote_element_count,
+ op->state->my_element_count,
+ GNUNET_CONTAINER_multihashmap_size (op->set->content->elements));
+ switch (op->state->phase)
+ {
+ case PHASE_INITIAL:
+ GNUNET_break_op (0);
+ fail_intersection_operation(op);
+ return;
+ case PHASE_COUNT_SENT:
+ /* This is the first BF being sent, build our initial map with
+ filtering in place */
+ op->state->my_element_count = 0;
+ GNUNET_CONTAINER_multihashmap_iterate (op->set->content->elements,
+ &filtered_map_initialization,
+ op);
+ break;
+ case PHASE_BF_EXCHANGE:
+ /* Update our set by reduction */
+ GNUNET_CONTAINER_multihashmap_iterate (op->state->my_elements,
+ &iterator_bf_reduce,
+ op);
+ break;
+ case PHASE_MUST_SEND_DONE:
+ GNUNET_break_op (0);
+ fail_intersection_operation(op);
+ return;
+ case PHASE_DONE_RECEIVED:
+ GNUNET_break_op (0);
+ fail_intersection_operation(op);
+ return;
+ case PHASE_FINISHED:
+ GNUNET_break_op (0);
+ fail_intersection_operation(op);
+ return;
+ }
+ GNUNET_CONTAINER_bloomfilter_free (op->state->remote_bf);
+ op->state->remote_bf = NULL;
+
+ if ( (0 == op->state->my_element_count) || /* fully disjoint */
+ ( (op->state->my_element_count == op->remote_element_count) &&
+ (0 == memcmp (&op->state->my_xor,
+ &op->state->other_xor,
+ sizeof (struct GNUNET_HashCode))) ) )
+ {
+ /* we are done */
+ op->state->phase = PHASE_MUST_SEND_DONE;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Intersection succeeded, sending DONE to other peer\n");
+ GNUNET_CONTAINER_bloomfilter_free (op->state->local_bf);
+ op->state->local_bf = NULL;
+ if (GNUNET_SET_RESULT_FULL == op->result_mode)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending full result set (%u elements)\n",
+ GNUNET_CONTAINER_multihashmap_size (op->state->my_elements));
+ op->state->full_result_iter
+ = GNUNET_CONTAINER_multihashmap_iterator_create (op->state->my_elements);
+ send_remaining_elements (op);
+ return;
+ }
+ send_p2p_done (op);
+ return;
+ }