mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Added path_nodes array and add_path_node() function.
This commit is contained in:
parent
545cc91662
commit
bb2a6cbbe2
|
@ -33,6 +33,26 @@
|
|||
#define ANNOUNCE_ARRAY_SIZE 256
|
||||
#define ANNOUNCE_TIMEOUT 10
|
||||
|
||||
/* Add a node to the path_nodes array.
|
||||
*
|
||||
* return -1 on failure
|
||||
* return 0 on success
|
||||
*/
|
||||
static int add_path_node(Onion_Client *onion_c, Node_format *node)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < MAX_PATH_NODES; ++i) {
|
||||
if (memcmp(node->client_id, onion_c->path_nodes[i].client_id, crypto_box_PUBLICKEYBYTES) == 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
onion_c->path_nodes[onion_c->path_nodes_index % MAX_PATH_NODES] = *node;
|
||||
|
||||
++onion_c->path_nodes_index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* return -1 if nodes are suitable for creating a new path.
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
#define MAX_STORED_PINGED_NODES 9
|
||||
#define MIN_NODE_PING_TIME 10
|
||||
|
||||
#define MAX_PATH_NODES 32
|
||||
|
||||
typedef struct {
|
||||
uint8_t client_id[CLIENT_ID_SIZE];
|
||||
IP_Port ip_port;
|
||||
|
@ -124,6 +126,9 @@ typedef struct {
|
|||
|
||||
Last_Pinged last_pinged[MAX_STORED_PINGED_NODES];
|
||||
|
||||
Node_format path_nodes[MAX_PATH_NODES];
|
||||
uint16_t path_nodes_index;
|
||||
|
||||
Ping_Array announce_ping_array;
|
||||
uint8_t last_pinged_index;
|
||||
struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user