Starting to make the daemon more intelligent
This commit is contained in:
parent
fbd862431c
commit
f8e4286740
7 changed files with 98 additions and 8 deletions
|
@ -5,18 +5,27 @@
|
|||
#include <pthread.h>
|
||||
#include "libp2p/net/p2pnet.h"
|
||||
#include "ipfs/core/daemon.h"
|
||||
#include "ipfs/core/ipfs_node.h"
|
||||
|
||||
int ipfs_daemon (int argc, char **argv)
|
||||
{
|
||||
int count_pths = 0;
|
||||
pthread_t work_pths[MAX];
|
||||
struct null_listen_params listen_param;
|
||||
struct IpfsNodeListenParams listen_param;
|
||||
|
||||
fprintf(stderr, "Initializing daemon...\n");
|
||||
|
||||
// create a new IpfsNode
|
||||
struct IpfsNode local_node;
|
||||
local_node.mode = MODE_ONLINE;
|
||||
//local_node.peerstore = ipfs_peerstore_new();
|
||||
//local_node.repo = fsrepo;
|
||||
//local_node.peer_id = peer_id;
|
||||
|
||||
// Set null router param
|
||||
listen_param.ipv4 = 0; // ip 0.0.0.0, all interfaces
|
||||
listen_param.port = 4001;
|
||||
listen_param.local_node = &local_node;
|
||||
|
||||
// Create pthread for ipfs_null_listen.
|
||||
if (pthread_create(&work_pths[count_pths++], NULL, ipfs_null_listen, &listen_param)) {
|
||||
|
|
37
core/net.c
Normal file
37
core/net.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
#include "ipfs/core/net.h"
|
||||
|
||||
/**
|
||||
* Do a socket accept
|
||||
* @param listener the listener
|
||||
* @returns true(1) on success, false(0) otherwise
|
||||
*/
|
||||
int ipfs_core_net_accept(struct IpfsListener listener) {
|
||||
//TODO: Implement this
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen using a particular protocol
|
||||
* @param node the node
|
||||
* @param protocol the protocol to use
|
||||
* @param listener the results
|
||||
* @returns true(1) on success, false(0) otherwise
|
||||
*/
|
||||
int ipfs_core_net_listen(struct IpfsNode* node, char* protocol, struct IpfsListener* listener){
|
||||
// TODO: Implement this
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***
|
||||
* Dial a peer
|
||||
* @param node this node
|
||||
* @param peer_id who to dial
|
||||
* @param protocol the protocol to use
|
||||
* @param stream the resultant stream
|
||||
* @returns true(1) on success, otherwise false(0)
|
||||
*/
|
||||
int ipsf_core_net_dial(struct IpfsNode* node, char* peer_id, char* protocol, struct Stream* stream) {
|
||||
//TODO: Implement this
|
||||
return 0;
|
||||
}
|
|
@ -44,10 +44,10 @@ void *ipfs_null_listen (void *ptr)
|
|||
{
|
||||
int socketfd, s, count = 0;
|
||||
pthread_t pth_connection;
|
||||
struct null_listen_params *listen_param;
|
||||
struct IpfsNodeListenParams *listen_param;
|
||||
struct null_connection_params *connection_param;
|
||||
|
||||
listen_param = (struct null_listen_params*) ptr;
|
||||
listen_param = (struct IpfsNodeListenParams*) ptr;
|
||||
|
||||
if ((socketfd = socket_listen(socket_tcp4(), &(listen_param->ipv4), &(listen_param->port))) <= 0) {
|
||||
perror("fail to init null router.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue