now puting result of get_value in the return buffer

yamux
jmjatlanta 2017-09-28 08:24:57 -05:00
parent 3d425bb30f
commit 296d164e84
3 changed files with 17 additions and 3 deletions

View File

@ -63,6 +63,7 @@ struct HttpResponse* ipfs_core_http_response_new() {
if (response != NULL) {
response->content_type = NULL;
response->bytes = NULL;
response->bytes_size = 0;
}
return response;
}

View File

@ -72,9 +72,17 @@ int ipfs_routing_generic_get_value (ipfs_routing* routing, const unsigned char *
libp2p_logger_error("offline", "Unable to call API for dht get.\n");
return 0;
}
//TODO: put results in val
fprintf(stdout, "%s", response);
return 1;
*vlen = strlen(response);
if (*vlen > 0) {
*val = malloc(*vlen + 1);
uint8_t* ptr = (uint8_t*)*val;
if (ptr == NULL) {
return 0;
}
memcpy(ptr, response, *vlen);
ptr[*vlen] = 0;
retVal = 1;
}
} else {
struct HashtableNode* node = NULL;
*val = NULL;

View File

@ -373,6 +373,9 @@ int ipfs_routing_online_get_value (ipfs_routing* routing, const unsigned char *k
struct Libp2pVector *peers = NULL;
int retVal = 0;
// just to be sure
*buffer_size = 0;
// find a provider
routing->FindProviders(routing, key, key_size, &peers);
if (peers == NULL) {
@ -423,6 +426,8 @@ int ipfs_routing_online_get_value (ipfs_routing* routing, const unsigned char *k
}
}
}
if (buffer_size == 0)
goto exit;
}
retVal = 1;