tweaks to bitswap message

This commit is contained in:
jmjatlanta 2017-07-31 15:19:17 -05:00
parent 835b70c97f
commit bc01f36839
2 changed files with 7 additions and 5 deletions

View file

@ -359,7 +359,7 @@ int ipfs_bitswap_wantlist_protobuf_decode(unsigned char* buffer, size_t buffer_l
if (buffer_length == 0)
return 1;
*output = (struct BitswapWantlist*) malloc(sizeof(struct BitswapWantlist));
*output = ipfs_bitswap_wantlist_new();
if (*output == NULL)
return 0;
@ -567,7 +567,7 @@ int ipfs_bitswap_message_protobuf_decode(const uint8_t* buffer, size_t buffer_le
if (buffer_length == 0)
return 1;
*output = (struct BitswapMessage*) malloc(sizeof(struct BitswapMessage));
*output = (struct BitswapMessage*) ipfs_bitswap_message_new();
if (*output == NULL)
return 0;

View file

@ -69,9 +69,11 @@ int ipfs_bitswap_network_handle_message(const struct IpfsNode* node, const struc
return 0;
// process the message
// payload - what we want
for(int i = 0; i < message->payload->total; i++) {
struct Block* blk = (struct Block*)libp2p_utils_vector_get(message->payload, i);
node->exchange->HasBlock(node->exchange, blk);
if (message->payload != NULL) {
for(int i = 0; i < message->payload->total; i++) {
struct Block* blk = (struct Block*)libp2p_utils_vector_get(message->payload, i);
node->exchange->HasBlock(node->exchange, blk);
}
}
// wantlist - what they want
if (message->wantlist != NULL && message->wantlist->entries != NULL && message->wantlist->entries->total > 0) {