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

Another JSON-RPC refactor #1415

Open
tomaka opened this issue Nov 26, 2023 · 2 comments
Open

Another JSON-RPC refactor #1415

tomaka opened this issue Nov 26, 2023 · 2 comments

Comments

@tomaka
Copy link
Contributor

tomaka commented Nov 26, 2023

This would be the third refactor of the JSON-RPC service, but I'm slowly learning how to do it properly.

This is how it would look like:

  • In lib.rs, add a "reverse proxy" that binds the socket (or equivalent) and the actual requests processor(s). The role of this reverse proxy is to maintain coherency from the socket point of view in case a requests processor crashes. It also has the responsibility of enforcing the number of subscriptions, to ensure equal balancing of requests when there is more than one JSON-RPC client, and to send unsubscribe requests if a client disconnects.

  • In light-base and full node, add a "requests processor": a single-threaded task (no sub-tasks) that processes requests either immediately or by pushing them to a FuturesUnordered. From the point of view of this requests processor, there is only a single JSON-RPC client. This requests processor would be relatively simple, as it doesn't need to handle everything handled by the reverse proxy.

  • In light-base and full node, connect the two with channels. The full node would have multiple requests processors.

@tomaka
Copy link
Contributor Author

tomaka commented Nov 27, 2023

cc #519 and to some extend #1382

@tomaka
Copy link
Contributor Author

tomaka commented Jan 23, 2024

Adding a single JSON-RPC reverse proxy (as in #1436) seems really over-complicated.

However, we can split it in two:

  • A "client sanitizer" that merges/discards notifications in case a JSON-RPC client is too slow, and also generates unsubscribe JSON-RPC requests when the client disconnects.
  • A "server dispatcher" that redirects requests to servers, and properly handles when a server is removed.

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

No branches or pull requests

1 participant