Network write methods now expect struct StreamMessage
This commit is contained in:
parent
9afaf535d6
commit
91f5c50a71
3 changed files with 15 additions and 4 deletions
|
@ -38,7 +38,10 @@ int ipfs_bitswap_network_send_message(const struct BitswapContext* context, stru
|
||||||
memcpy(buf, "/ipfs/bitswap/1.1.0\n", 20);
|
memcpy(buf, "/ipfs/bitswap/1.1.0\n", 20);
|
||||||
buf_size += 20;
|
buf_size += 20;
|
||||||
// send it
|
// send it
|
||||||
int bytes_written = peer->sessionContext->default_stream->write(peer->sessionContext, buf, buf_size);
|
struct StreamMessage outgoing;
|
||||||
|
outgoing.data = buf;
|
||||||
|
outgoing.data_size = buf_size;
|
||||||
|
int bytes_written = peer->sessionContext->default_stream->write(peer->sessionContext, &outgoing);
|
||||||
if (bytes_written <= 0) {
|
if (bytes_written <= 0) {
|
||||||
free(buf);
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -167,7 +167,10 @@ struct HashtableNode* ipfs_resolver_remote_get(const char* path, struct Hashtabl
|
||||||
// switch to kademlia
|
// switch to kademlia
|
||||||
if (!libp2p_routing_dht_upgrade_stream(&session_context))
|
if (!libp2p_routing_dht_upgrade_stream(&session_context))
|
||||||
return NULL;
|
return NULL;
|
||||||
stream->write(&session_context, message_protobuf, message_protobuf_size);
|
struct StreamMessage outgoing;
|
||||||
|
outgoing.data = message_protobuf;
|
||||||
|
outgoing.data_size = message_protobuf_size;
|
||||||
|
stream->write(&session_context, &outgoing);
|
||||||
struct StreamMessage* response;
|
struct StreamMessage* response;
|
||||||
// we should get back a protobuf'd record
|
// we should get back a protobuf'd record
|
||||||
stream->read(&session_context, &response, 5);
|
stream->read(&session_context, &response, 5);
|
||||||
|
|
|
@ -116,10 +116,15 @@ int ipfs_journal_send_message(struct IpfsNode* node, struct Libp2pPeer* peer, st
|
||||||
return 0;
|
return 0;
|
||||||
// send the header
|
// send the header
|
||||||
char* header = "/ipfs/journalio/1.0.0\n";
|
char* header = "/ipfs/journalio/1.0.0\n";
|
||||||
if (!peer->sessionContext->default_stream->write(peer->sessionContext, (unsigned char*)header, strlen(header)))
|
struct StreamMessage outgoing;
|
||||||
|
outgoing.data = (uint8_t*)header;
|
||||||
|
outgoing.data_size = strlen(header);
|
||||||
|
if (!peer->sessionContext->default_stream->write(peer->sessionContext, &outgoing))
|
||||||
return 0;
|
return 0;
|
||||||
// send the message
|
// send the message
|
||||||
return peer->sessionContext->default_stream->write(peer->sessionContext, msg, msg_size);
|
outgoing.data = msg;
|
||||||
|
outgoing.data_size = msg_size;
|
||||||
|
return peer->sessionContext->default_stream->write(peer->sessionContext, &outgoing);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
|
Loading…
Reference in a new issue