Added some debugging info
This commit is contained in:
parent
01531693d6
commit
396a27d712
2 changed files with 14 additions and 2 deletions
|
@ -92,16 +92,22 @@ void *ipfs_null_connection (void *ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (protocol_compare(results, bytes_read, "/kad/")) {
|
} 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;
|
break;
|
||||||
|
}
|
||||||
// this handles 1 transaction
|
// this handles 1 transaction
|
||||||
libp2p_routing_dht_handle_message(&session, connection_param->local_node->peerstore, connection_param->local_node->providerstore);
|
libp2p_routing_dht_handle_message(&session, connection_param->local_node->peerstore, connection_param->local_node->providerstore);
|
||||||
|
fprintf(stderr, "kademlia message handled\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// oops there was a problem
|
// oops there was a problem
|
||||||
//TODO: Handle this
|
//TODO: Handle this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Multistream negotiation failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.default_stream != NULL) {
|
if (session.default_stream != NULL) {
|
||||||
|
|
|
@ -97,10 +97,12 @@ int ipfs_ping (int argc, char **argv)
|
||||||
goto exit;
|
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)) {
|
if (!libp2p_secio_handshake(&session, &fs_repo->config->identity->private_key, 0)) {
|
||||||
fprintf(stderr, "Unable to switch to secure connection. Attempting insecure ping...\n");
|
fprintf(stderr, "Unable to switch to secure connection. Attempting insecure ping...\n");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// prepare the PING message
|
// prepare the PING message
|
||||||
msg = libp2p_message_new();
|
msg = libp2p_message_new();
|
||||||
|
@ -109,6 +111,10 @@ int ipfs_ping (int argc, char **argv)
|
||||||
protobuf_size = libp2p_message_protobuf_encode_size(msg);
|
protobuf_size = libp2p_message_protobuf_encode_size(msg);
|
||||||
protobuf = (unsigned char*)malloc(protobuf_size);
|
protobuf = (unsigned char*)malloc(protobuf_size);
|
||||||
libp2p_message_protobuf_encode(msg, &protobuf[0], protobuf_size, &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->write(&session, protobuf, protobuf_size);
|
||||||
session.default_stream->read(&session, &results, &results_size);
|
session.default_stream->read(&session, &results, &results_size);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue