+
+ return GNUNET_CONTAINER_multipeermap_put (finger_peermap,
+ &(new_finger_entry->finger_identity),
+ new_finger_entry,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+}
+
+
+/**
+ * 1. removed predecessor_finger_id check as in select_closest_finger we check it
+ * and handle it accordingly.
+ * 2. you don't handle the second trail here as in new entry you will have only
+ * one trail to reach to the finger.
+ * 3. check how do you handle the return value of this function.
+ * FIXME: Functions calling finger_table_add will not check if finger identity
+ * and my identity are same, it should be done in this function.
+ * Add an entry in the finger table. If there is already an existing entry in
+ * the finger peermap for given finger map index, then choose the closest one.
+ * In case both the new entry and old entry are same, store both of them. (Redundant
+ * routing).
+ * @param finger_identity
+ * @param finger_trail
+ * @param finger_trail_length
+ * @param finger_map_index
+ * @return #GNUNET_YES if the new entry is added.
+ * #GNUNET_NO if the new entry is discarded.
+ */
+static
+int finger_table_add (const struct GNUNET_PeerIdentity *finger_identity,
+ struct GNUNET_PeerIdentity *finger_trail,
+ uint32_t finger_trail_length,
+ uint32_t finger_map_index)
+{
+ struct FingerInfo *existing_finger;
+ struct GNUNET_CONTAINER_MultiPeerMapIterator *finger_iter;
+ int i;
+ int new_entry_added = GNUNET_NO;
+
+ /* Check if there is already an entry for the finger map index in the finger peer map. */
+ finger_iter = GNUNET_CONTAINER_multipeermap_iterator_create (finger_peermap);
+ for (i= 0; i < GNUNET_CONTAINER_multipeermap_size (finger_peermap); i++)
+ {
+ if(GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next (finger_iter, NULL,
+ (const void **)&existing_finger))
+ {
+ if (existing_finger->finger_map_index == finger_map_index)
+ {
+ if ( GNUNET_NO == select_closest_finger (existing_finger, finger_identity,
+ finger_trail, finger_trail_length,finger_map_index))
+ goto update_current_search_finger_index;
+ else
+ break;
+ }
+ }
+ }
+ GNUNET_CONTAINER_multipeermap_iterator_destroy (finger_iter);