examples: Adjust example to return subscription ID

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2022-11-24 17:01:47 +00:00
parent ad57b95811
commit 33b4eb7e1d
+4 -2
View File
@@ -16,6 +16,7 @@ use subxt::{
RpcClientT, RpcClientT,
RpcFuture, RpcFuture,
RpcSubscription, RpcSubscription,
RpcSubscriptionId,
}, },
OnlineClient, OnlineClient,
PolkadotConfig, PolkadotConfig,
@@ -54,7 +55,7 @@ impl RpcClientT for MyLoggingClient {
sub: &'a str, sub: &'a str,
params: Option<Box<RawValue>>, params: Option<Box<RawValue>>,
unsub: &'a str, unsub: &'a str,
) -> RpcFuture<'a, RpcSubscription> { ) -> RpcFuture<'a, (RpcSubscription, Option<RpcSubscriptionId>)> {
writeln!( writeln!(
self.log.lock().unwrap(), self.log.lock().unwrap(),
"{sub}({}) (unsub: {unsub})", "{sub}({}) (unsub: {unsub})",
@@ -68,7 +69,8 @@ impl RpcClientT for MyLoggingClient {
let res = RawValue::from_string("[]".to_string()).unwrap(); let res = RawValue::from_string("[]".to_string()).unwrap();
let stream = futures::stream::once(async move { Ok(res) }); let stream = futures::stream::once(async move { Ok(res) });
let stream: Pin<Box<dyn futures::Stream<Item = _> + Send>> = Box::pin(stream); let stream: Pin<Box<dyn futures::Stream<Item = _> + Send>> = Box::pin(stream);
Box::pin(std::future::ready(Ok(stream))) // This subscription does not provide an ID.
Box::pin(std::future::ready(Ok((stream, None))))
} }
} }