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

rpc: Expose the subscription ID for RpcClientT #733

Merged
merged 5 commits into from Nov 25, 2022

Conversation

lexnv
Copy link
Contributor

@lexnv lexnv commented Nov 24, 2022

Extent the RpcClientT to obtain the ID associated with subscriptions.

To ensure that this extension is not impacting users that do not want to
implement/return it, the subscription ID is optional.

The subscription ID needs to be exposed for implementing #732.

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv self-assigned this Nov 24, 2022
Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -62,3 +62,6 @@ pub type RpcFuture<'a, T> =
/// The inner subscription stream returned from our [`RpcClientT`]'s `subscription` method.
pub type RpcSubscription =
Pin<Box<dyn Stream<Item = Result<Box<RawValue>, RpcError>> + Send + 'static>>;

/// The ID associated with the [`RpcClientT`]'s `subscription`.
pub type RpcSubscriptionId = String;
Copy link
Member

Choose a reason for hiding this comment

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

This is configurable in substrate via the SubscriptionIdProvider so it could something different than String. Should be String 99% of cases anyway but just saying.

Does the new rpc api v2 specify the format of the subscription ID? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The RPC layer should take the subscriptionID as a parameter in string format. From chainHead_unstable_body:

followSubscription: An opaque string that was returned by chainHead_unstable_follow.

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv merged commit 463e2aa into master Nov 25, 2022
@lexnv lexnv deleted the lexnv/rpc_subscription_id branch November 25, 2022 15:07
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.

None yet

4 participants