Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Question about running swarm.peers() in setInterval #970

Closed
JohnAllen opened this issue Aug 30, 2017 · 3 comments
Closed

Question about running swarm.peers() in setInterval #970

JohnAllen opened this issue Aug 30, 2017 · 3 comments
Labels
kind/support A question or request for support

Comments

@JohnAllen
Copy link

JohnAllen commented Aug 30, 2017

Question

Low

Description:

@diasdavid: in this comment you said: Let's try one more thing, spawn several browser tabs with your code and instead of doing just once node.swarm.peers do it in a setInterval. . How does this work? Is it simply: running this function more than once tells the network to connect to more peers?`. This seems to be the case because the more times it is run the more peers I have. Wondering if there is more to it than that.

@daviddias
Copy link
Member

oh these magic black boxes :) 🎩

ipfs.swarm.peers lists the peers connected, connecting to a peer is not instance, it has to go through an intense handshake of multistream -> secio -> multistream -> multiplex -> multistream, which can take some seconds per peer. The reason why you see more and more is because your now is not only connecting to the bootstrapper nodes, it is also connecting to other nodes it discovers and so, over time, the peer list will increase.

@daviddias daviddias added the kind/support A question or request for support label Aug 30, 2017
@daviddias
Copy link
Member

@JohnAllen do you feel your question got answered?

@JohnAllen
Copy link
Author

Yes, thanks, meant to close!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

2 participants