Added some debugging info

This commit is contained in:
John Jones 2017-04-03 12:42:35 -05:00
parent 01531693d6
commit 396a27d712
2 changed files with 14 additions and 2 deletions

View file

@ -92,16 +92,22 @@ void *ipfs_null_connection (void *ptr)
}
}
} else if (protocol_compare(results, bytes_read, "/kad/")) {
if (!libp2p_routing_dht_handshake(&session))
fprintf(stderr, "Attempting kademlia connection...\n");
if (!libp2p_routing_dht_handshake(&session)) {
fprintf(stderr, "kademlia connection handshake failed\n");
break;
}
// this handles 1 transaction
libp2p_routing_dht_handle_message(&session, connection_param->local_node->peerstore, connection_param->local_node->providerstore);
fprintf(stderr, "kademlia message handled\n");
}
else {
// oops there was a problem
//TODO: Handle this
}
}
} else {
fprintf(stderr, "Multistream negotiation failed\n");
}
if (session.default_stream != NULL) {

View file

@ -97,10 +97,12 @@ int ipfs_ping (int argc, char **argv)
goto exit;
}
// try to switch to secio
//TODO: Fix mac problem, then use this to try to switch to secio
/*
if (!libp2p_secio_handshake(&session, &fs_repo->config->identity->private_key, 0)) {
fprintf(stderr, "Unable to switch to secure connection. Attempting insecure ping...\n");
}
*/
// prepare the PING message
msg = libp2p_message_new();
@ -109,6 +111,10 @@ int ipfs_ping (int argc, char **argv)
protobuf_size = libp2p_message_protobuf_encode_size(msg);
protobuf = (unsigned char*)malloc(protobuf_size);
libp2p_message_protobuf_encode(msg, &protobuf[0], protobuf_size, &protobuf_size);
if (!libp2p_routing_dht_upgrade_stream(&session)) {
fprintf(stderr, "PING unsuccessful. Unable to switch to kademlia protocol\n");
goto exit;
}
session.default_stream->write(&session, protobuf, protobuf_size);
session.default_stream->read(&session, &results, &results_size);