From 5e8683e64daebf63cd1bdd603ded345a36d38eb9 Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 9 Aug 2017 12:34:02 -0500 Subject: [PATCH] Cleaning up old code --- core/null.c | 77 ----------------------------------- test/routing/test_supernode.h | 13 +++--- 2 files changed, 8 insertions(+), 82 deletions(-) diff --git a/core/null.c b/core/null.c index dc1f14e..3ea6fa8 100644 --- a/core/null.c +++ b/core/null.c @@ -31,83 +31,6 @@ static int null_shutting_down = 0; -/*** - * Handle the incoming request from a Multistream - * @param incoming the incoming request - * @param incoming_size the size of the request in bytes - * @param session the session context - * @param connection_param the connection parameters - * @returns 1 to indicate it was handled, 0 to indicate that the daemon should no longer loop (future messages will be handled by another message loop), and -1 to indicate a problem - */ -int ipfs_multistream_marshal(const unsigned char* incoming, size_t incoming_size, struct SessionContext* session, struct IpfsNode* local_node) { - /* to be deleted after we get rid of nodeio*/ - /* - if (protocol_compare(incoming, incoming_size, "/secio")) { - libp2p_logger_debug("null", "Attempting secure io connection...\n"); - if (!libp2p_secio_handshake(session, &local_node->identity->private_key, local_node->peerstore, 1)) { - // rejecting connection - libp2p_logger_debug("null", "Secure IO connection failed\n"); - return -1; - } - libp2p_logger_debug("null", "Secure IO connection successful.\n"); - return 0; - } else if (protocol_compare(incoming, incoming_size, "/nodeio")) { - libp2p_logger_debug("null", "Attempting a nodeio connection.\n"); - if (!libp2p_nodeio_handshake(session)) { - return -1; - } - // loop through file requests - int _continue = 1; - while(_continue) { - unsigned char* hash; - size_t hash_length = 0; - _continue = session->default_stream->read(session, &hash, &hash_length, DEFAULT_NETWORK_TIMEOUT); - if (hash_length < 20) { - _continue = 0; - continue; - } - else { - // try to get the Node - struct HashtableNode* node = NULL; - if (!ipfs_merkledag_get(hash, hash_length, &node, local_node->repo)) { - _continue = 0; - continue; - } - size_t results_size = ipfs_hashtable_node_protobuf_encode_size(node); - unsigned char results[results_size]; - if (!ipfs_hashtable_node_protobuf_encode(node, results, results_size, &results_size)) { - _continue = 0; - continue; - } - // send it to the requestor - session->default_stream->write(session, results, results_size); - } - } - } else if (protocol_compare(incoming, incoming_size, "/ipfs/kad/")) { - libp2p_logger_log("null", LOGLEVEL_DEBUG, "Attempting kademlia connection...\n"); - if (!libp2p_routing_dht_handshake(session)) { - libp2p_logger_log("null", LOGLEVEL_DEBUG, "kademlia connection handshake failed\n"); - return -1; - } - // this handles 1 transaction - libp2p_routing_dht_handle_message(session, local_node->peerstore, local_node->providerstore); - libp2p_logger_log("null", LOGLEVEL_DEBUG, "kademlia message handled\n"); - } else if (protocol_compare(incoming, incoming_size, "/ipfs/bitswap/")) { - libp2p_logger_debug("null", "Attempting bitswap connection...\n"); - if (!ipfs_bitswap_network_handle_message(local_node, session, incoming, incoming_size)) { - libp2p_logger_error("null", "Bitswap message handler reported a failure.\n"); - return -1; - } - } - else { - libp2p_logger_error("null", "There was a problem with this connection. It is nothing I can handle. Disconnecting.\n"); - return -1; - } -*/ - return 1; - -} - /** * We've received a connection. Find out what they want. * diff --git a/test/routing/test_supernode.h b/test/routing/test_supernode.h index 848598b..7bcb9b8 100644 --- a/test/routing/test_supernode.h +++ b/test/routing/test_supernode.h @@ -53,6 +53,8 @@ void* start_daemon(void* path) { } int test_routing_supernode_get_remote_value() { + return 0; + /* // a remote machine has a file. Let's see if we can get it. // the key is QmYAXgX8ARiriupMQsbGXtKdDyGzWry1YV3sycKw1qqmgH, which is the test_file.txt int retVal = 0; @@ -152,9 +154,12 @@ int test_routing_supernode_get_remote_value() { if (multiaddresses != NULL) libp2p_utils_vector_free(multiaddresses); return retVal; + */ } int test_routing_supernode_get_value() { + return 0; + /* int retVal = 0; struct FSRepo* fs_repo = NULL; struct IpfsNode* ipfs_node = NULL; @@ -209,10 +214,8 @@ int test_routing_supernode_get_value() { } // announce to network that this can be provided - /* - if (!ipfs_node->routing->Provide(ipfs_node->routing, (unsigned char*)write_node->hash, write_node->hash_size)) - goto exit; - */ + //if (!ipfs_node->routing->Provide(ipfs_node->routing, (unsigned char*)write_node->hash, write_node->hash_size)) + // goto exit; // ask the network who can provide this if (!ipfs_node->routing->FindProviders(ipfs_node->routing, write_node->hash, write_node->hash_size, &multiaddresses)) @@ -266,5 +269,5 @@ int test_routing_supernode_get_value() { if (multiaddresses != NULL) libp2p_utils_vector_free(multiaddresses); return retVal; - + */ }