summaryrefslogtreecommitdiff
path: root/other/DHT_bootstrap.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-01 23:02:13 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-16 21:01:43 +0000
commitd6d305feeb76735ee4b4e14c6bca737a5482bc19 (patch)
tree99005c635a452245006b3b5de44f1dd80da9f77f /other/DHT_bootstrap.c
parent54066f338f185f2fbd6694d9a4877f42cbfa21c8 (diff)
Use per-instance `Mono_Time` for Messenger and onion.
Diffstat (limited to 'other/DHT_bootstrap.c')
-rw-r--r--other/DHT_bootstrap.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index fc1bba47..6af042ac 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -115,12 +115,11 @@ int main(int argc, char *argv[])
115 IP ip; 115 IP ip;
116 ip_init(&ip, ipv6enabled); 116 ip_init(&ip, ipv6enabled);
117 117
118 unix_time_update();
119
120 Logger *logger = logger_new(); 118 Logger *logger = logger_new();
121 DHT *dht = new_dht(logger, new_networking(logger, ip, PORT), true); 119 Mono_Time *mono_time = mono_time_new();
122 Onion *onion = new_onion(dht); 120 DHT *dht = new_dht(logger, mono_time, new_networking(logger, ip, PORT), true);
123 Onion_Announce *onion_a = new_onion_announce(dht); 121 Onion *onion = new_onion(mono_time, dht);
122 Onion_Announce *onion_a = new_onion_announce(mono_time, dht);
124 123
125#ifdef DHT_NODE_EXTRA_PACKETS 124#ifdef DHT_NODE_EXTRA_PACKETS
126 bootstrap_set_callbacks(dht_get_net(dht), DHT_VERSION_NUMBER, DHT_MOTD, sizeof(DHT_MOTD)); 125 bootstrap_set_callbacks(dht_get_net(dht), DHT_VERSION_NUMBER, DHT_MOTD, sizeof(DHT_MOTD));
@@ -188,7 +187,7 @@ int main(int argc, char *argv[])
188 lan_discovery_init(dht); 187 lan_discovery_init(dht);
189 188
190 while (1) { 189 while (1) {
191 unix_time_update(); 190 mono_time_update(mono_time);
192 191
193 if (is_waiting_for_dht_connection && dht_isconnected(dht)) { 192 if (is_waiting_for_dht_connection && dht_isconnected(dht)) {
194 printf("Connected to other bootstrap node successfully.\n"); 193 printf("Connected to other bootstrap node successfully.\n");
@@ -197,13 +196,13 @@ int main(int argc, char *argv[])
197 196
198 do_dht(dht); 197 do_dht(dht);
199 198
200 if (is_timeout(last_LANdiscovery, is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL)) { 199 if (mono_time_is_timeout(mono_time, last_LANdiscovery, is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL)) {
201 lan_discovery_send(net_htons(PORT), dht); 200 lan_discovery_send(net_htons(PORT), dht);
202 last_LANdiscovery = unix_time(); 201 last_LANdiscovery = mono_time_get(mono_time);
203 } 202 }
204 203
205#ifdef TCP_RELAY_ENABLED 204#ifdef TCP_RELAY_ENABLED
206 do_TCP_server(tcp_s); 205 do_TCP_server(tcp_s, mono_time);
207#endif 206#endif
208 networking_poll(dht_get_net(dht), nullptr); 207 networking_poll(dht_get_net(dht), nullptr);
209 208