aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_nse.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-21 05:51:38 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-21 05:51:38 +0000
commita864897478e2ee94ab36648e7f1db6f0dd57ea43 (patch)
tree70d3026143ff9285691325ee4b243a6a2361cbd7 /src/dht/gnunet-service-dht_nse.c
parentf591bfdc7b28e93b9412c2d9e031c8848ce90f55 (diff)
downloadgnunet-a864897478e2ee94ab36648e7f1db6f0dd57ea43.tar.gz
gnunet-a864897478e2ee94ab36648e7f1db6f0dd57ea43.zip
add
Diffstat (limited to 'src/dht/gnunet-service-dht_nse.c')
-rw-r--r--src/dht/gnunet-service-dht_nse.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/dht/gnunet-service-dht_nse.c b/src/dht/gnunet-service-dht_nse.c
new file mode 100644
index 000000000..4711c9c31
--- /dev/null
+++ b/src/dht/gnunet-service-dht_nse.c
@@ -0,0 +1,84 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file dht/gnunet-service-dht_nse.c
23 * @brief GNUnet DHT integration with NSE
24 * @author Christian Grothoff
25 */
26#include "gnunet-service-dht.h"
27#include "gnunet-service-dht_nse.h"
28
29/**
30 * log of the current network size estimate, used as the point where
31 * we switch between random and deterministic routing. Default
32 * value of 4.0 is used if NSE module is not available (i.e. not
33 * configured).
34 */
35static double log_of_network_size_estimate = 4.0;
36
37/**
38 * Network size estimation handle.
39 */
40static struct GNUNET_NSE_Handle *nse;
41
42
43/**
44 * Callback that is called when network size estimate is updated.
45 *
46 * @param cls closure
47 * @param timestamp time when the estimate was received from the server (or created by the server)
48 * @param logestimate the log(Base 2) value of the current network size estimate
49 * @param std_dev standard deviation for the estimate
50 *
51 */
52static void
53update_network_size_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp,
54 double logestimate, double std_dev)
55{
56 log_of_network_size_estimate = logestimate;
57}
58
59
60double
61GDS_nse_get ()
62{
63 return log_of_network_size_estimate;
64}
65
66
67void
68GDS_nse_init ()
69{
70 nse = GNUNET_NSE_connect (GDS_cfg, &update_network_size_estimate, NULL);
71}
72
73
74void
75GDS_nse_done ()
76{
77 if (NULL != nse)
78 {
79 GNUNET_NSE_disconnect (nse);
80 nse = NULL;
81 }
82}
83
84/* end of gnunet-service-dht_nse.c */