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

Allow instantiation with existing ws #49

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

adrianhopebailie
Copy link
Contributor

This change is required by interledgerjs/ilp-connector#476

It allows an AccountProvider in the connector to create new instances of the plugin from sockets that are created by a WS server running outside the plugin.

src/index.ts Outdated Show resolved Hide resolved
@@ -120,6 +123,58 @@ describe('BtpPlugin', function () {
})
})

describe('can pass in websocket connection', function () {

beforeEach(async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of this project is 2-space indented.

@@ -132,6 +132,9 @@ export interface IlpPluginBtpConstructorOptions {
port: number,
secret: string
},
raw?: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for this extra layer of indirection?

Also, from the option alone it isn't clear whether the created plugin will act as a client or server. Maybe it should be server_socket (in the top-level options), or listener.socket.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a reason for this extra layer of indirection?

Good suggestion. I think listener.socket makes the most sense.

Also, from the option alone it isn't clear whether the created plugin will act as a client or server.

The plugin is not going to act as a WS server because it is created around an existing ws socket so it's not listening for new connections.

BUT it will handle incoming auth messages (i.e. it's a "BTP server" in as much as the difference between a client and server is that one performs auth with the other even though they may actually be peers)

This is a general problem (I think) with the architecture of the plugin in that it mixes the transport (websockets) with the protocol (BTP).

I tried a more decoupled approach with ilp-transport, interested to hear what you think of that and if we could move to something similar with BTP: https://github.com/adrianhopebailie/ilp-transport

@sublimator sublimator closed this Jun 22, 2022
@sublimator sublimator reopened this Jun 22, 2022
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.

4 participants