diff options
Diffstat (limited to 'src/dht/gnunet-service-dht_nse.c')
-rw-r--r-- | src/dht/gnunet-service-dht_nse.c | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/src/dht/gnunet-service-dht_nse.c b/src/dht/gnunet-service-dht_nse.c deleted file mode 100644 index 58f18816a..000000000 --- a/src/dht/gnunet-service-dht_nse.c +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009, 2010, 2011 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your 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 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
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 "platform.h" | ||
27 | #include "gnunet_nse_service.h" | ||
28 | #include "gnunet-service-dht.h" | ||
29 | #include "gnunet-service-dht_nse.h" | ||
30 | |||
31 | /** | ||
32 | * log of the current network size estimate, used as the point where | ||
33 | * we switch between random and deterministic routing. Default | ||
34 | * value of 4.0 is used if NSE module is not available (i.e. not | ||
35 | * configured). | ||
36 | */ | ||
37 | static double log_of_network_size_estimate = 4.0; | ||
38 | |||
39 | /** | ||
40 | * Network size estimation handle. | ||
41 | */ | ||
42 | static struct GNUNET_NSE_Handle *nse; | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Callback that is called when network size estimate is updated. | ||
47 | * | ||
48 | * @param cls closure | ||
49 | * @param timestamp time when the estimate was received from the server (or created by the server) | ||
50 | * @param logestimate the log(Base 2) value of the current network size estimate | ||
51 | * @param std_dev standard deviation for the estimate | ||
52 | * | ||
53 | */ | ||
54 | static void | ||
55 | update_network_size_estimate (void *cls, | ||
56 | struct GNUNET_TIME_Absolute timestamp, | ||
57 | double logestimate, | ||
58 | double std_dev) | ||
59 | { | ||
60 | GNUNET_STATISTICS_update (GDS_stats, | ||
61 | "# Network size estimates received", | ||
62 | 1, GNUNET_NO); | ||
63 | /* do not allow estimates < 0.5 */ | ||
64 | log_of_network_size_estimate = GNUNET_MAX (0.5, logestimate); | ||
65 | } | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Return the log of the current network size estimate. | ||
70 | * | ||
71 | * @return log of NSE | ||
72 | */ | ||
73 | double | ||
74 | GDS_NSE_get () | ||
75 | { | ||
76 | return log_of_network_size_estimate; | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Initialize NSE subsystem. | ||
82 | */ | ||
83 | void | ||
84 | GDS_NSE_init () | ||
85 | { | ||
86 | unsigned long long hops; | ||
87 | |||
88 | if ( (GNUNET_YES == | ||
89 | GNUNET_CONFIGURATION_have_value (GDS_cfg, | ||
90 | "dht", | ||
91 | "FORCE_NSE")) && | ||
92 | (GNUNET_OK == | ||
93 | GNUNET_CONFIGURATION_get_value_number (GDS_cfg, | ||
94 | "dht", | ||
95 | "FORCE_NSE", | ||
96 | &hops)) ) | ||
97 | { | ||
98 | log_of_network_size_estimate = (double) hops; | ||
99 | return; | ||
100 | } | ||
101 | nse = GNUNET_NSE_connect (GDS_cfg, | ||
102 | &update_network_size_estimate, | ||
103 | NULL); | ||
104 | } | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Shutdown NSE subsystem. | ||
109 | */ | ||
110 | void | ||
111 | GDS_NSE_done () | ||
112 | { | ||
113 | if (NULL != nse) | ||
114 | { | ||
115 | GNUNET_NSE_disconnect (nse); | ||
116 | nse = NULL; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | |||
121 | /* end of gnunet-service-dht_nse.c */ | ||