*/
static struct RPSPeer *rps_peers;
+/**
+ * Peermap to get the index of a given peer ID quick.
+ */
+static struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
+
/**
* IDs of the peers.
*/
tofile_(file_name,tmp_buf);\
} while (0);
+
/**
* Write the ids and their according index in the given array to a file
* Unused
rps_peers[entry->index].rec_ids = NULL;
rps_peers[entry->index].num_rec_ids = 0;
+ GNUNET_CONTAINER_multipeermap_put (peer_map,
+ &rps_peer_ids[entry->index],
+ &rps_peers[entry->index],
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+
tofile ("/tmp/rps/peer_ids",
"%u\t%s\n",
entry->index,
const struct GNUNET_PeerIdentity *recv_peers)
{
struct RPSPeer *rps_peer = (struct RPSPeer *) cls;
+ struct RPSPeer *rcv_rps_peer;
char *file_name;
+ char *file_name_dh;
unsigned int i;
file_name = "/tmp/rps/received_ids";
+ file_name_dh = "/tmp/rps/diehard_input";
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"[%s] got %" PRIu64 " peers:\n",
tofile (file_name,
"%s\n",
GNUNET_i2s_full (&recv_peers[i]));
+
+ rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, &recv_peers[i]);
+
+ tofile (file_name_dh,
+ "%" PRIu32 "\n",
+ (uint32_t) rcv_rps_peer->index);
}
}
int
main (int argc, char *argv[])
{
+ int ret_value;
+
cur_test_run.name = "test-rps-default";
cur_test_run.pre_test = NULL;
cur_test_run.reply_handle = default_reply_handle;
rps_peers = GNUNET_new_array (num_peers, struct RPSPeer);
rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity);
+ peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO);
ok = 1;
(void) GNUNET_TESTBED_test_run (cur_test_run.name,
0, NULL, NULL,
&run, NULL);
- return cur_test_run.eval_cb();
+ ret_value = cur_test_run.eval_cb();
+
+ GNUNET_free (rps_peers );
+ GNUNET_free (rps_peer_ids);
+ GNUNET_CONTAINER_multipeermap_destroy (peer_map);
+
+ return ret_value;
}
/* end of test_rps_multipeer.c */