Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the purpose of the promptedNetwork logic? #182

Open
jacobheun opened this issue Sep 4, 2018 · 1 comment
Open

What is the purpose of the promptedNetwork logic? #182

jacobheun opened this issue Sep 4, 2018 · 1 comment
Labels
kind/support A question or request for support status/ready Ready to be worked

Comments

@jacobheun
Copy link
Contributor

I was working on an example project and noticed some extra network calls when cat'ing content, which led me to the code:

if (!promptedNetwork) {
promptedNetwork = true
this.network.findAndConnect(cids[0], (err) => {
if (err) {
this._log.error(err)
}
})
}

During getMany if the content doesn't exist locally, this block is triggered along with an external search for the content. The find and connect only applies to the first cid in the getMany request and only if it doesn't exist locally.

Since there are no comments around the code I'm not clear what the goal of this is. I presume this is to be proactive about connecting to peers that have content you're looking for, is that correct? What's the reason behind only using the first cid? Is it assumed that the other cids will exist on the found providers as well?

@jacobheun jacobheun added the kind/support A question or request for support label Sep 4, 2018
@jacobheun jacobheun changed the title What is the purpose of the networkPrompted logic? What is the purpose of the promptedNetwork logic? Sep 4, 2018
@daviddias
Copy link
Member

findAndConnect need to be implemented once Peer Routing exists (find the peer and connect to it).

The find and connect only applies to the first cid in the getMany request and only if it doesn't exist locally.

We do a DHT Query just on the root node as we try to be optimistic and avoid smashing the DHT. Who has the root node potentially has the rest of the file too.

@daviddias daviddias added the status/deferred Conscious decision to pause or backlog label Oct 27, 2018
@daviddias daviddias added status/ready Ready to be worked and removed status/deferred Conscious decision to pause or backlog labels Dec 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support A question or request for support status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

2 participants