-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
@alanshaw if this looks good my thought for testing is to just add spies on the upgrader to verify the methods are called, and return a cc: @vasco-santos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just one suggestion
README.md
Outdated
|
||
This method uses a transport to dial a Peer listening on `multiaddr`. | ||
|
||
`multiaddr` must be of the type [`multiaddr`](https://www.npmjs.com/multiaddr). | ||
|
||
`[options]` the options that may be passed to the dial. Must support the `signal` option (see below) | ||
|
||
`conn` must implement the [interface-connection](https://github.com/libp2p/interface-connection) interface. | ||
Dial **MUST** call and return `upgrader.upgradeOutbound({ source, sink, conn, remoteAddr })`. The upgrader will return an [interface-connection](https://github.com/libp2p/interface-connection) instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's worth creating a definition of { source, sink, conn, remoteAddr }
as MultiaddrConnection
somewhere so we can refer to it better here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking interface-connection initially, but I think it's better in the readme here since it's specific to transports.
@alanshaw @vasco-santos I have added tests to dial and listen. Test setup now takes The tests now validate the respective spies are called, and that the connections returned from the transport (both dial and listen), are the same values returned by the upgrader spies. I did some quick hacks locally on the existing |
This has been released as 0.6.0. |
As part of the migration to async await, and in order to add better flexibility to libp2p connection upgrades, Transports will now take, and be required to support using an
Upgrader
instance.Upgraders have 2 methods:
upgradeOutbound
andupgradeInbound
.upgradeOutbound
must be called and returned bytransport.dial
.upgradeInbound
must be called and the results must be passed to thecreateListener
handlerFunction
and theconnection
event handler, anytime a new connection is created.The
Upgrader
methods will returninterface-connection
instances, the new API for which is being solidified at libp2p/interface-connection#29.