Fixed adding to list of peers.
This commit is contained in:
parent
57d04eb1c3
commit
44cf00432b
13
src/node.c
13
src/node.c
@ -1556,6 +1556,7 @@ int bootstrap_node(int * sock_fd, char * root_peer_ip, uint16_t root_peer_port){
|
||||
struct addrinfo *p;
|
||||
struct neighbour_peer *peer ;
|
||||
|
||||
list * tmp = neighbour_list;
|
||||
for(p = res; p != NULL; p = p->ai_next) {
|
||||
peer = (neighbour_peer*) malloc(sizeof(neighbour_peer));
|
||||
memcpy(&peer->ip, &((struct sockaddr_in6 *) p->ai_addr)->sin6_addr, sizeof(struct in6_addr));
|
||||
@ -1571,7 +1572,7 @@ int bootstrap_node(int * sock_fd, char * root_peer_ip, uint16_t root_peer_port){
|
||||
printf("\x1b[31m[DEBUG]\x1b[0m >> Adding %s @ %i to peer list.\n", ip_str, root_peer_port );
|
||||
}
|
||||
|
||||
list * tmp = neighbour_list;
|
||||
|
||||
|
||||
// Add new peer to the list.
|
||||
list *node = (list*) malloc(sizeof(list));
|
||||
@ -1579,14 +1580,16 @@ int bootstrap_node(int * sock_fd, char * root_peer_ip, uint16_t root_peer_port){
|
||||
node->next = NULL;
|
||||
|
||||
// Goint to the end of the list
|
||||
while(tmp->data != NULL){
|
||||
while(tmp->next != NULL){
|
||||
tmp = tmp->next;
|
||||
}
|
||||
tmp->data = node;
|
||||
tmp->next = NULL;
|
||||
|
||||
tmp->next = node;
|
||||
}
|
||||
|
||||
neighbour_list = tmp;
|
||||
|
||||
|
||||
print_peers(neighbour_list);
|
||||
|
||||
print_debug(">> Initializing data list...");
|
||||
data_list = (list*) malloc(sizeof(list));
|
||||
|
Loading…
Reference in New Issue
Block a user