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

Update selection mechanism to connect to peers - Closes #3346 #4022

Merged

Conversation

diego-G
Copy link

@diego-G diego-G commented Jul 30, 2019

How to manually test it?

npm test

Review checklist

@diego-G diego-G force-pushed the 3346-update_peer_selection_multiple branch from 1f8baed to b6d73a1 Compare July 30, 2019 15:03
Copy link
Contributor

@ishantiw ishantiw left a comment

Choose a reason for hiding this comment

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

I think these calculations need to be moved to peer_book, we can expose a combined list of new/triedPeer using this calculation using a function (something like peerBook.getPeersForSelection) in this way we don't need to pass around new/triedPeers logic to peer_pool, peer_selection, etc. The peer_selection function for connection can be used for more higher-level logic for selection like peers having the same modules or greater height, etc.

Maybe this PR should go after #4030 so that we have more clarity.

@diego-G diego-G requested a review from ishantiw August 1, 2019 11:43
@diego-G
Copy link
Author

diego-G commented Aug 1, 2019

@ishantiw as discussed, let's work on this idea after we merge the current PR and we review yours.

elements/lisk-p2p/src/peer_selection.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_selection.ts Outdated Show resolved Hide resolved
elements/lisk-p2p/src/peer_selection.ts Outdated Show resolved Hide resolved
@diego-G diego-G force-pushed the 3346-update_peer_selection_multiple branch from 2469918 to 0c71956 Compare August 1, 2019 14:34
@diego-G diego-G requested a review from jondubois August 1, 2019 14:35
Copy link
Contributor

@ishantiw ishantiw left a comment

Choose a reason for hiding this comment

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

Approving, let's tackle the placement of logic(new/triedPeer) related to peer selection in another PR

}

return shuffledTriedPeers.splice(0, 1)[0];
return shuffledTriedPeers.pop() as P2PPeerInfo;
Copy link
Contributor

@jondubois jondubois Aug 2, 2019

Choose a reason for hiding this comment

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

This one could be undefined if the shuffledTriedPeers and shuffledNewPeers lengths are both 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or if shuffledNewPeers is 0 and the if (Math.random() < r) block is not executed for shuffledTriedPeers.

Copy link
Author

@diego-G diego-G Aug 2, 2019

Choose a reason for hiding this comment

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

Those two cases are covered above. Have a look! Also there are unit test double checking it.

}

return shuffledTriedPeers.splice(0, 1)[0];
return shuffledTriedPeers.pop() as P2PPeerInfo;
Copy link
Contributor

Choose a reason for hiding this comment

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

Or if shuffledNewPeers is 0 and the if (Math.random() < r) block is not executed for shuffledTriedPeers.

@diego-G diego-G requested review from pablitovicente and removed request for mitsuaki-u August 2, 2019 10:15
@jondubois jondubois merged commit e5887a8 into feature/implement-lip-p2p Aug 2, 2019
@diego-G diego-G deleted the 3346-update_peer_selection_multiple branch August 5, 2019 15:09
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.

None yet

5 participants