Null routing code reallocated to facilitate routing protocol swap.

This commit is contained in:
Jose Marcial Vieira Bisneto 2017-07-06 23:51:53 -03:00
parent 8da685b5cf
commit 13b8b8bf27
5 changed files with 13 additions and 5 deletions

View file

@ -31,12 +31,12 @@ int ipfs_daemon_start(char* repo_path) {
listen_param.local_node = local_node;
// Create pthread for swarm listener.
if (pthread_create(&work_pths[count_pths++], NULL, ipfs_null_listen, &listen_param)) {
if (pthread_create(&work_pths[count_pths++], NULL, local_node->routing->Listen, &listen_param)) {
libp2p_logger_error("daemon", "Error creating thread for ipfs null listen\n");
goto exit;
}
//ipfs_bootstrap_routing(local_node);
local_node->routing->Bootstrap (local_node->routing);
libp2p_logger_info("daemon", "Daemon for %s is ready on port %d\n", listen_param.local_node->identity->peer_id, listen_param.port);

View file

@ -26,9 +26,6 @@ struct IpfsNodeListenParams {
struct IpfsNode* local_node;
};
//void *ipfs_null_connection (void *ptr);
void *ipfs_null_listen (void *ptr);
int ipfs_null_shutdown();
int ipfs_daemon (int argc, char **argv);
int ipfs_daemon_start(char* repo_path);
int ipfs_daemon_stop();

6
include/ipfs/core/null.h Normal file
View file

@ -0,0 +1,6 @@
#pragma once
void *ipfs_null_connection (void *ptr);
void *ipfs_null_listen (void *ptr);
int ipfs_null_shutdown();

View file

@ -73,6 +73,8 @@ struct IpfsRouting {
* @returns true(1) on success, otherwise false(0)
*/
int (*Bootstrap) (struct IpfsRouting*);
void (*Listen) (void*);
int (*Shutdown) ();
};
typedef struct IpfsRouting ipfs_routing;

View file

@ -1,6 +1,7 @@
#include <stdlib.h>
#include "ipfs/routing/routing.h"
#include "ipfs/core/null.h"
#include "libp2p/record/message.h"
#include "libp2p/net/stream.h"
#include "libp2p/conn/session.h"
@ -515,6 +516,8 @@ ipfs_routing* ipfs_routing_new_online (struct IpfsNode* local_node, struct RsaPr
onlineRouting->Provide = ipfs_routing_online_provide;
onlineRouting->Ping = ipfs_routing_online_ping;
onlineRouting->Bootstrap = ipfs_routing_online_bootstrap;
onlineRouting->Listen = ipfs_null_listen;
onlineRouting->Shutdown = ipfs_null_shutdown;
}
onlineRouting->local_node->mode = MODE_ONLINE;