forked from agorise/c-ipfs
More changes to swarm negotiation
This commit is contained in:
parent
b72f247939
commit
0c31ef7331
3 changed files with 5 additions and 4 deletions
|
@ -90,8 +90,8 @@ int ipfs_node_online_new(const char* repo_path, struct IpfsNode** node) {
|
||||||
// fill in the node
|
// fill in the node
|
||||||
local_node->repo = fs_repo;
|
local_node->repo = fs_repo;
|
||||||
local_node->identity = fs_repo->config->identity;
|
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->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->providerstore = libp2p_providerstore_new(fs_repo->config->datastore, local_node->identity->peer);
|
||||||
local_node->blockstore = ipfs_blockstore_new(fs_repo);
|
local_node->blockstore = ipfs_blockstore_new(fs_repo);
|
||||||
local_node->protocol_handlers = ipfs_node_online_build_protocol_handlers(local_node);
|
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
|
// fill in the node
|
||||||
local_node->repo = fs_repo;
|
local_node->repo = fs_repo;
|
||||||
local_node->identity = fs_repo->config->identity;
|
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->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->providerstore = libp2p_providerstore_new(fs_repo->config->datastore, local_node->identity->peer);
|
||||||
local_node->blockstore = ipfs_blockstore_new(fs_repo);
|
local_node->blockstore = ipfs_blockstore_new(fs_repo);
|
||||||
local_node->protocol_handlers = ipfs_node_online_build_protocol_handlers(local_node);
|
local_node->protocol_handlers = ipfs_node_online_build_protocol_handlers(local_node);
|
||||||
|
|
|
@ -112,7 +112,8 @@ int ipfs_null_do_maintenance(struct IpfsNode* local_node, struct Libp2pPeer* pee
|
||||||
ipfs_journal_sync(local_node, replication_peer);
|
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));
|
libp2p_logger_debug("null", "Sync message sent. Maintenance complete for node %s.\n", libp2p_peer_id_to_string(peer));
|
||||||
} else {
|
} 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
|
// try a ping, but only if we're connected
|
||||||
libp2p_logger_debug("null", "Attempting ping of %s.\n", libp2p_peer_id_to_string(peer));
|
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)) {
|
if (peer->connection_type == CONNECTION_TYPE_CONNECTED && !local_node->routing->Ping(local_node->routing, peer)) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ int test_ping() {
|
||||||
remote_peer->addr_head->item = multiaddress_new_from_string("/ip4/192.168.43.234/tcp/4001/");
|
remote_peer->addr_head->item = multiaddress_new_from_string("/ip4/192.168.43.234/tcp/4001/");
|
||||||
|
|
||||||
// connect using a dialer
|
// 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);
|
conn = libp2p_conn_dialer_get_connection(dialer, remote_peer->addr_head->item);
|
||||||
|
|
||||||
//TODO: Dialer should know the protocol
|
//TODO: Dialer should know the protocol
|
||||||
|
|
Loading…
Reference in a new issue