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

Improve peer selection #96

Closed
karmacoma opened this issue Apr 12, 2017 · 1 comment
Closed

Improve peer selection #96

karmacoma opened this issue Apr 12, 2017 · 1 comment

Comments

@karmacoma
Copy link
Contributor

Expected behaviour

If there is a failure to connect to a selected peer, then another peer on the same network should be chosen.

Actual behaviour

If there is a failure to connect to a selected peer, then the current behaviour results in another mainnet peer being selected, regardless of whether a peer on another network was selected.

Steps to reproduce

Select a localhost peer even though there is no instance of Lisk running locally. Perform an API request. Connection will timeout / fail, resulting in a change of peer to one of the predefined mainnet peers. If the intention was to connect to the testnet or a local devnet, the current behaviour would be undesirable.

Possible Solution

Assuming, upon catching an error, the switch is being here: https://github.com/LiskHQ/lisk-js/blob/development/lib/api/liskApi.js#L203.

Then improve information available to selectNode: https://github.com/LiskHQ/lisk-js/blob/development/lib/api/liskApi.js#L143, by allowing the developer to optionally indicate their chosen network using an appropriate nethash.

Then if a nethash is provided, restrict the peer selection to the chosen network. Allowing the switch to occur when matching. Throwing an error when there are no matching peers.

@toschdev
Copy link
Contributor

Today I am coming back to this issue. We also had several discussions on this. So my proposal would be the following behaviour:

  1. When a user enters a node himself, the default behaviour should be that lisk-js does not change peers on its own. This can be enabled with setting a node AND using randomPeer: true on the settings.

  2. Lisk-JS should be checking for a user entered nethash. When the user has entered the nethash, it should compare to the given testnet and mainnet nethashes. When it does match, the specified network can be chosen to discover a new peer. When it does not match, no peer shall be chosen.

@karmacoma karmacoma removed this from Ready in Version 1.0.0 Apr 27, 2017
@karmacoma karmacoma added this to In Progress in Version 0.4.1 Apr 27, 2017
@karmacoma karmacoma added *medium and removed *hard labels Apr 27, 2017
@karmacoma karmacoma removed this from In Progress in Version 0.4.1 Apr 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants