1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 19:53:25 +01:00

connect to limited number of nodes on init instead of all of them

This commit is contained in:
Jfreegman 2014-02-24 20:08:51 -05:00
parent e7920d1da7
commit 2d9f4facf7
2 changed files with 8 additions and 5 deletions

View File

@ -205,6 +205,8 @@ int init_connection_helper(Tox *m, int line)
*/
static bool srvlist_loaded = false;
#define NUM_INIT_NODES 5
int init_connection(Tox *m)
{
if (linecnt > 0) /* already loaded serverlist */
@ -231,10 +233,11 @@ int init_connection(Tox *m)
return 2;
res = 3;
int line;
int i;
int n = MIN(NUM_INIT_NODES, linecnt);
for(line = 0; line < linecnt; line++)
if (init_connection_helper(m, line))
for(i = 0; i < n; ++i)
if (init_connection_helper(m, rand() % linecnt))
res = 0;
return res;

View File

@ -2,8 +2,8 @@
* Toxic -- Tox Curses Client
*/
// #define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
/* convert a hex string to binary */
unsigned char *hex_string_to_bin(char hex_string[]);