Big changes for the yamux protocol

The Stream interface changed, so it touches many areas. But this change
will help with memory allocation and a cleaner interface.
This commit is contained in:
John Jones 2017-11-08 10:54:31 -05:00
parent 8b2a8ef3ab
commit 6160dd841b
6 changed files with 28 additions and 28 deletions

View file

@ -7,6 +7,7 @@
#include "libp2p/os/utils.h"
#include "libp2p/utils/logger.h"
#include "libp2p/net/stream.h"
#include "libp2p/net/connectionstream.h"
#include "ipfs/core/ipfs_node.h"
#include "ipfs/datastore/ds_helper.h"
#include "ipfs/exchange/exchange.h"
@ -35,8 +36,11 @@ int ipfs_bitswap_shutdown_handler(void* context) {
* @param protocol_context the protocol-dependent context
* @returns 0 if the caller should not continue looping, <0 on error, >0 on success
*/
int ipfs_bitswap_handle_message(const struct StreamMessage* msg, struct SessionContext* session_context, void* protocol_context) {
int ipfs_bitswap_handle_message(const struct StreamMessage* msg, struct Stream* stream, void* protocol_context) {
struct IpfsNode* local_node = (struct IpfsNode*)protocol_context;
struct SessionContext* session_context = libp2p_net_connection_get_session_context(stream);
if (session_context == NULL)
return -1;
int retVal = ipfs_bitswap_network_handle_message(local_node, session_context, msg->data, msg->data_size);
if (retVal == 0)
return -1;

View file

@ -108,7 +108,7 @@ void* ipfs_bitswap_engine_peer_request_processor_start(void* ctx) {
if (current_peer_entry->sessionContext->default_stream->read(current_peer_entry->sessionContext, &buffer, 1)) {
// handle it
libp2p_logger_debug("bitswap_engine", "%lu bytes read, result: [%s].\n", buffer->data_size, buffer->data);
int retVal = libp2p_protocol_marshal(buffer, current_peer_entry->sessionContext, context->ipfsNode->protocol_handlers);
int retVal = libp2p_protocol_marshal(buffer, current_peer_entry->sessionContext->default_stream, context->ipfsNode->protocol_handlers);
libp2p_stream_message_free(buffer);
did_some_processing = 1;
if (retVal == -1) {