Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: specify subscriptions as a series of OpenRPC fragments #2

Merged
merged 3 commits into from
Jul 5, 2024

Conversation

aatifsyed
Copy link

@aatifsyed aatifsyed commented Jul 1, 2024

I've got low confidence on what this actually looks like for Lotus - our code is certainly inconsistent.

@elmattic could you review, and also provide a trace of all JSON messages (with origins) for the full lifecycle when speaking to Lotus?

@aatifsyed aatifsyed self-assigned this Jul 1, 2024
@elmattic
Copy link

elmattic commented Jul 4, 2024

Here's a breakdown of messages between a WebSocket client (User) and Lotus (Node):

Subscription

User to Node:

{"jsonrpc":"2.0","id":23,"method":"Filecoin.ChainNotify","params":[]}

I've chosen to init subscription with id set to 23 so it differs from the channelID.
Here id can be of type:

  • Number
  • String

Subscription response

Node to User:

{"jsonrpc":"2.0","result":1,"id":23}

Here result contains the channelID. channelID must be of type Number.


Notification*

Node to User:

{"jsonrpc":"2.0","method":"xrpc.ch.val","params":[1,<payload>]}

Here params is of type List and the first element corresponds to the channelID of the subscription.

The second element is the notification value.

(*) User can get zero, one or many notifications.


Channel cancelation

User to Node:

{"jsonrpc":"2.0","method":"xrpc.cancel","params":[23]}

Here params is of type List and the first element is the subscription id.


Channel cancelation response

Node to User:

{"jsonrpc":"2.0","method":"xrpc.ch.close","params":[1]}

Here params is of type List and the first element is the channelID.

@aatifsyed
Copy link
Author

Excellent, thanks @elmattic that answers all the questions :)

@aatifsyed aatifsyed changed the title specify subscriptions as a series of OpenRPC fragments feat: specify subscriptions as a series of OpenRPC fragments Jul 5, 2024
@aatifsyed aatifsyed merged commit dac0552 into ansermino/rpc-api Jul 5, 2024
1 check passed
@aatifsyed aatifsyed deleted the aatifsyed/common-node-api branch July 5, 2024 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants