From 0c31ef7331c7dbc71c2990688ef101e72d2a1dfc Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 25 Oct 2017 12:29:20 -0500 Subject: [PATCH] More changes to swarm negotiation --- core/ipfs_node.c | 4 ++-- core/null.c | 3 ++- test/core/test_ping.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/ipfs_node.c b/core/ipfs_node.c index 5847b8c..6a61dc7 100644 --- a/core/ipfs_node.c +++ b/core/ipfs_node.c @@ -90,8 +90,8 @@ int ipfs_node_online_new(const char* repo_path, struct IpfsNode** node) { // fill in the node local_node->repo = fs_repo; local_node->identity = fs_repo->config->identity; - local_node->dialer = libp2p_conn_dialer_new(local_node->identity->peer, &local_node->identity->private_key); local_node->peerstore = libp2p_peerstore_new(local_node->identity->peer); + local_node->dialer = libp2p_conn_dialer_new(local_node->identity->peer, local_node->peerstore, &local_node->identity->private_key); local_node->providerstore = libp2p_providerstore_new(fs_repo->config->datastore, local_node->identity->peer); local_node->blockstore = ipfs_blockstore_new(fs_repo); local_node->protocol_handlers = ipfs_node_online_build_protocol_handlers(local_node); @@ -136,8 +136,8 @@ int ipfs_node_offline_new(const char* repo_path, struct IpfsNode** node) { // fill in the node local_node->repo = fs_repo; local_node->identity = fs_repo->config->identity; - local_node->dialer = libp2p_conn_dialer_new(local_node->identity->peer, &local_node->identity->private_key); local_node->peerstore = libp2p_peerstore_new(local_node->identity->peer); + local_node->dialer = libp2p_conn_dialer_new(local_node->identity->peer, local_node->peerstore, &local_node->identity->private_key); local_node->providerstore = libp2p_providerstore_new(fs_repo->config->datastore, local_node->identity->peer); local_node->blockstore = ipfs_blockstore_new(fs_repo); local_node->protocol_handlers = ipfs_node_online_build_protocol_handlers(local_node); diff --git a/core/null.c b/core/null.c index 06c77a9..f96d7d6 100644 --- a/core/null.c +++ b/core/null.c @@ -112,7 +112,8 @@ int ipfs_null_do_maintenance(struct IpfsNode* local_node, struct Libp2pPeer* pee ipfs_journal_sync(local_node, replication_peer); libp2p_logger_debug("null", "Sync message sent. Maintenance complete for node %s.\n", libp2p_peer_id_to_string(peer)); } else { - if (peer->sessionContext != NULL && os_utils_gmtime() - peer->sessionContext->last_comm_epoch > 180) { + unsigned long long last_comm = libp2p_peer_last_comm(peer); + if (os_utils_gmtime() - last_comm > 180) { // try a ping, but only if we're connected libp2p_logger_debug("null", "Attempting ping of %s.\n", libp2p_peer_id_to_string(peer)); if (peer->connection_type == CONNECTION_TYPE_CONNECTED && !local_node->routing->Ping(local_node->routing, peer)) { diff --git a/test/core/test_ping.h b/test/core/test_ping.h index 9f54196..86e120a 100644 --- a/test/core/test_ping.h +++ b/test/core/test_ping.h @@ -55,7 +55,7 @@ int test_ping() { remote_peer->addr_head->item = multiaddress_new_from_string("/ip4/192.168.43.234/tcp/4001/"); // connect using a dialer - dialer = libp2p_conn_dialer_new(fs_repo->config->identity->peer, &fs_repo->config->identity->private_key); + dialer = libp2p_conn_dialer_new(fs_repo->config->identity->peer, NULL, NULL); conn = libp2p_conn_dialer_get_connection(dialer, remote_peer->addr_head->item); //TODO: Dialer should know the protocol