diff options
Diffstat (limited to 'toxcore/DHT.h')
-rw-r--r-- | toxcore/DHT.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/toxcore/DHT.h b/toxcore/DHT.h index c213da42..aea3d73b 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h | |||
@@ -31,8 +31,13 @@ | |||
31 | /* Maximum number of clients stored per friend. */ | 31 | /* Maximum number of clients stored per friend. */ |
32 | #define MAX_FRIEND_CLIENTS 8 | 32 | #define MAX_FRIEND_CLIENTS 8 |
33 | 33 | ||
34 | #define LCLIENT_NODES (MAX_FRIEND_CLIENTS) | ||
35 | #define LCLIENT_LENGTH 128 | ||
36 | |||
34 | /* A list of the clients mathematically closest to ours. */ | 37 | /* A list of the clients mathematically closest to ours. */ |
35 | #define LCLIENT_LIST 32 | 38 | #define LCLIENT_LIST (LCLIENT_LENGTH * LCLIENT_NODES) |
39 | |||
40 | #define MAX_CLOSE_TO_BOOTSTRAP_NODES 8 | ||
36 | 41 | ||
37 | /* The max number of nodes to send with send nodes. */ | 42 | /* The max number of nodes to send with send nodes. */ |
38 | #define MAX_SENT_NODES 4 | 43 | #define MAX_SENT_NODES 4 |
@@ -58,7 +63,7 @@ | |||
58 | #define TOX_TCP_INET6 138 | 63 | #define TOX_TCP_INET6 138 |
59 | 64 | ||
60 | /* The number of "fake" friends to add (for optimization purposes and so our paths for the onion part are more random) */ | 65 | /* The number of "fake" friends to add (for optimization purposes and so our paths for the onion part are more random) */ |
61 | #define DHT_FAKE_FRIEND_NUMBER 4 | 66 | #define DHT_FAKE_FRIEND_NUMBER 2 |
62 | 67 | ||
63 | /* Functions to transfer ips safely across wire. */ | 68 | /* Functions to transfer ips safely across wire. */ |
64 | void to_net_family(IP *ip); | 69 | void to_net_family(IP *ip); |
@@ -232,7 +237,7 @@ typedef struct { | |||
232 | 237 | ||
233 | Cryptopacket_Handles cryptopackethandlers[256]; | 238 | Cryptopacket_Handles cryptopackethandlers[256]; |
234 | 239 | ||
235 | Node_format to_bootstrap[MAX_SENT_NODES]; | 240 | Node_format to_bootstrap[MAX_CLOSE_TO_BOOTSTRAP_NODES]; |
236 | unsigned int num_to_bootstrap; | 241 | unsigned int num_to_bootstrap; |
237 | } DHT; | 242 | } DHT; |
238 | /*----------------------------------------------------------------------------------*/ | 243 | /*----------------------------------------------------------------------------------*/ |
@@ -307,6 +312,10 @@ int id_closest(const uint8_t *pk, const uint8_t *pk1, const uint8_t *pk2); | |||
307 | _Bool add_to_list(Node_format *nodes_list, unsigned int length, const uint8_t *pk, IP_Port ip_port, | 312 | _Bool add_to_list(Node_format *nodes_list, unsigned int length, const uint8_t *pk, IP_Port ip_port, |
308 | const uint8_t *cmp_pk); | 313 | const uint8_t *cmp_pk); |
309 | 314 | ||
315 | /* Return 1 if node can be added to close list, 0 if it can't. | ||
316 | */ | ||
317 | _Bool node_addable_to_close_list(DHT *dht, const uint8_t *public_key, IP_Port ip_port); | ||
318 | |||
310 | /* Get the (maximum MAX_SENT_NODES) closest nodes to public_key we know | 319 | /* Get the (maximum MAX_SENT_NODES) closest nodes to public_key we know |
311 | * and put them in nodes_list (must be MAX_SENT_NODES big). | 320 | * and put them in nodes_list (must be MAX_SENT_NODES big). |
312 | * | 321 | * |