Refactor the JSON-RPC service code #793
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #786
The plan in #786 has been implemented as described.
This PR entirely removes the
requests_subscriptions
module, as it was over-complicated.Rather than have one object dedicated to the entire JSON-RPC state, this PR introduces the
ClientMainTask
, which is specific to an individual JSON-RPC client.The
ClientMainTask
is basically a state machine with two channels plugged to it: one channel that allows sending requests and responses with the task responsible for the socket (SerializedRequestsIo
), and one channel where responses and subscriptions can send responses and notifications.However, the code that the API user writes is much more simple, as evidenced by the diff.
This PR breaks the fact that unsubscription requests must match the type of the subscription. For example, you can call
state_subscribeStorage
to subscribe, then callauthor_unwatchExtrinsic
to unsubscribe and it will succeed. As this is a pretty minor problem, I'm not fixing this right now, as it will be more easily fixable after some slightly further refactoring to have stronger typing for the different types of requests.This PR also removes the
max_parallel_subscription_updates
config option, as it is now irrelevant. Assigning priorities to tasks is better done by adjusting the executor rather than trying to game how said executor works.