Adding kademlia routing to daemon

This commit is contained in:
John Jones 2017-03-09 18:03:21 -05:00
parent 43ca313854
commit f494344b15
5 changed files with 107 additions and 5 deletions

View file

@ -28,3 +28,16 @@ void *ipfs_bootstrap_swarm(void* param) {
}
return (void*)1;
}
/***
* Listen for connections on the API port (usually 5001)
* NOTE: This fills in the IpfsNode->routing struct
*
* @param param the IpfsNode information
* @returns nothing useful
*/
void *ipfs_bootstrap_routing(void* param) {
struct IpfsNode* local_node = (struct IpfsNode*)param;
local_node->routing = ipfs_routing_new_kademlia(local_node, local_node->identity->private_key, NULL);
return NULL;
}

View file

@ -40,15 +40,15 @@ int ipfs_daemon_start(char* repo_path) {
listen_param.port = 4001;
listen_param.local_node = &local_node;
// Create pthread for ipfs_null_listen.
// Create pthread for swarm listener.
if (pthread_create(&work_pths[count_pths++], NULL, ipfs_null_listen, &listen_param)) {
fprintf(stderr, "Error creating thread for ipfs_null_listen\n");
return 1;
}
// create pthread for connecting to the swarm bootstrap
if (pthread_create(&work_pths[count_pths++], NULL, ipfs_bootstrap_swarm, &local_node)) {
// create pthread for the API
if (pthread_create(&work_pths[count_pths++], NULL, ipfs_bootstrap_routing, &local_node)) {
fprintf(stderr, "Error creating thread for routing\n");
}
fprintf(stderr, "Daemon is ready\n");