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

fix: dial in series until we have proper abort support #306

Merged
merged 2 commits into from
Mar 5, 2019

Conversation

jacobheun
Copy link
Contributor

@jacobheun jacobheun commented Mar 5, 2019

Currently the switch will dial all addresses for a particular transport in parallel. Since we don't have any real abort support for when a dial succeeds, we should resort to dialing in serial to avoid flooding a peer with unused connections. This may result in slower dials to peers, but should also prevent flooding connections. As we improve the logic of dialing, and add proper abort support, we should be able to dial in parallel, select the best connection and abort the rest.

The first connection to succeed will be used. Circuit is already dialed last, so we don't need to worry about using Circuit if we're able to dial the node directly.


This also improves the stability of the transport tests by moving tryEcho calls inside the dial callbacks, and adds an after handler to ensure the switch's are properly stopped after each transport suite is finished.

refactor: simplify the circuit dial logic

chore: remove travis windows cache

refactor: clean up dial many error logic

test: explicitly set correct address

test(refactor): update order of echo logic and add after
@ghost ghost assigned jacobheun Mar 5, 2019
@ghost ghost added the in progress label Mar 5, 2019
@jacobheun jacobheun requested a review from vasco-santos March 5, 2019 11:04
Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

Awesome jacob! This looks good and will really help now!

Just added a minor comment here

))
}
return this.close(Errors.CONNECTION_FAILED(
new Error(`No available transports to dial peer ${this.theirB58Id}!`)
Copy link
Member

Choose a reason for hiding this comment

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

add errcode here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Errors.CONNECTION_FAILED is a wrapper function that generates errCode errors.

https://github.com/libp2p/js-libp2p-switch/blob/v0.41.5/src/errors.js

Copy link
Member

Choose a reason for hiding this comment

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

Ok, my bad. So, we do not need to create the new Error here. It can be omitted and errCode will handle it.

@jacobheun jacobheun merged commit ddf622b into master Mar 5, 2019
@ghost ghost removed the in progress label Mar 5, 2019
@jacobheun jacobheun deleted the fix/performance branch March 5, 2019 17:46
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