From 069379acf4f49a3ee5036448f33c3afe0832f3d7 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 17 Jul 2017 13:05:56 -0500 Subject: [PATCH] Fix of a few compiler warnings --- README.md | 11 +++++++++++ core/daemon.c | 4 ++++ core/null.c | 6 ++++-- core/ping.c | 5 ++++- include/ipfs/routing/routing.h | 2 +- test/node/test_node.h | 4 ++++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d3d336f..45d7f4e 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,14 @@ getting started: https://github.com/ipfs/specs/blob/master/overviews/implement-i specifications: https://github.com/ipfs/specs
getting started: https://github.com/ipfs/community/issues/177
libp2p: https://github.com/libp2p/specs
+
+Prerequisites: To compile the C version you will need:
+lmdb https://github.com/jmjatlanta/lmdb
+c-protobuf https://github.com/kenCode/c-protobuf
+c-multihash https://github.com/kenCode/c-multihash
+c-multiaddr https://github.com/kenCode/c-multiaddr
+c-libp2p https://github.com/kenCode/c-libp2p
+
+And of course this project at https://github.com/kenCode/c-ipfs
+
+The compilation at this point is simple, but not very flexible. Place all of these projects in a directory. Compile all (the order above is recommended) by going into each one and running "make all". diff --git a/core/daemon.c b/core/daemon.c index eeb6cf4..dadfeab 100644 --- a/core/daemon.c +++ b/core/daemon.c @@ -6,6 +6,7 @@ #include "libp2p/net/p2pnet.h" #include "libp2p/peer/peerstore.h" #include "ipfs/core/daemon.h" +#include "ipfs/core/null.h" // for ipfs_null_shutdown #include "ipfs/core/ipfs_node.h" #include "ipfs/core/bootstrap.h" #include "ipfs/repo/fsrepo/fs_repo.h" @@ -18,6 +19,9 @@ int ipfs_daemon_start(char* repo_path) { struct IpfsNodeListenParams listen_param; struct MultiAddress* ma = NULL; + // Debugging JMJ + libp2p_logger_add_class("null"); + libp2p_logger_info("daemon", "Initializing daemon...\n"); struct IpfsNode* local_node = NULL; diff --git a/core/null.c b/core/null.c index c13240e..45b7be6 100644 --- a/core/null.c +++ b/core/null.c @@ -61,7 +61,7 @@ void ipfs_null_connection (void *ptr) libp2p_logger_log("null", LOGLEVEL_INFO, "Connection %d, count %d\n", connection_param->file_descriptor, *(connection_param->count)); - if (libp2p_net_multistream_negotiate(session)) { + if (libp2p_net_multistream_negotiate(&session)) { for(;;) { // check if they're looking for an upgrade (i.e. secio) @@ -86,6 +86,7 @@ void ipfs_null_connection (void *ptr) free(results); break; } + libp2p_logger_debug("null", "Secure IO connection successful.\n"); } else if (protocol_compare(results, bytes_read, "/nodeio")) { libp2p_logger_debug("null", "Attempting a nodeio connection.\n"); if (!libp2p_nodeio_handshake(&session)) { @@ -153,7 +154,7 @@ void ipfs_null_connection (void *ptr) return; } -void *ipfs_null_listen (void *ptr) +void* ipfs_null_listen (void *ptr) { int socketfd, s, count = 0; threadpool thpool = thpool_init(25); @@ -170,6 +171,7 @@ void *ipfs_null_listen (void *ptr) libp2p_logger_error("null", "Ipfs listening on %d\n", listen_param->port); for (;;) { + libp2p_logger_debug("null", "Attempting socket read\n"); int numDescriptors = socket_read_select4(socketfd, 2); if (null_shutting_down) { break; diff --git a/core/ping.c b/core/ping.c index 0a423ab..7d09267 100644 --- a/core/ping.c +++ b/core/ping.c @@ -96,10 +96,13 @@ int ipfs_ping (int argc, char **argv) } gettimeofday(&time2, NULL); + // calculate microseconds time_us = (time2.tv_sec - time1.tv_sec) * 1000000; time_us += (time2.tv_usec - time1.tv_usec); fprintf (stderr, "Pong received: time=%d.%03d ms\n", time_us / 1000, time_us % 1000); - usleep(1000000 - time_us); + if (time_us < 1000000) { // if the ping took less than a second... + sleep(1); + } } retVal = 1; diff --git a/include/ipfs/routing/routing.h b/include/ipfs/routing/routing.h index 59188dc..d32cd84 100644 --- a/include/ipfs/routing/routing.h +++ b/include/ipfs/routing/routing.h @@ -73,7 +73,7 @@ struct IpfsRouting { * @returns true(1) on success, otherwise false(0) */ int (*Bootstrap) (struct IpfsRouting*); - void (*Listen) (void*); + void* (*Listen) (void*); int (*Shutdown) (); }; typedef struct IpfsRouting ipfs_routing; diff --git a/test/node/test_node.h b/test/node/test_node.h index ccd57e2..aca3e34 100644 --- a/test/node/test_node.h +++ b/test/node/test_node.h @@ -1,5 +1,9 @@ #include "ipfs/merkledag/node.h" +/*** + * Testing of storage nodes. Nodes can be directories, files, or sections of a file. + */ + int test_node() { //Variables of link: char * name = "Alex";