forked from agorise/c-ipfs
Cleaning up old code
This commit is contained in:
parent
0e24b0a1d3
commit
5e8683e64d
2 changed files with 8 additions and 82 deletions
77
core/null.c
77
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.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue