Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

fix: put query for closest peers #85

Merged
merged 1 commit into from
Mar 4, 2019

Conversation

vasco-santos
Copy link
Member

@vasco-santos vasco-santos commented Mar 1, 2019

When we have a big number of peers, the query does not stop and put hangs, also hitting heavily the CPU. Moreover, we will get a really big set of peers from the closestPeers and trying to put to all of them also cause problems, as some end up failing, which causes the put operation to fail.

In a long run, we have to refactor the closestPeers and query logic to be more fault tolerant. We should stream the query as we would be able to stop the query at a certain point (should have an abort logic). I will create an issue for this afterward.

@ghost ghost assigned vasco-santos Mar 1, 2019
@ghost ghost added the status/in-progress In progress label Mar 1, 2019
@vasco-santos vasco-santos force-pushed the fix/put-query-for-closest-peers branch from 1dd3f43 to 23635ae Compare March 1, 2019 16:19
src/index.js Outdated
* @param {function(Error, Array<PeerId>)} callback
* @returns {void}
*/
getClosestPeers (key, callback) {
getClosestPeers (key, isOneIteration, callback) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isOneIteration should be an options object for better future proofing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll likely refactor this away anyway, but perhaps it might be good to use a more generic term like shallow, as it's possible we may use that later. The name change isn't a blocker though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, I have updated!

@vasco-santos vasco-santos force-pushed the fix/put-query-for-closest-peers branch from 23635ae to 7b80020 Compare March 4, 2019 10:44
@vasco-santos vasco-santos merged commit 84a40cd into master Mar 4, 2019
@ghost ghost removed the status/in-progress In progress label Mar 4, 2019
@vasco-santos vasco-santos deleted the fix/put-query-for-closest-peers branch March 4, 2019 11:05
@vasco-santos
Copy link
Member Author

I will open the issue for revisiting this logic!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants