From 79579c97a962af26ee8c9d201693a7f7fc0e635d Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Mon, 11 Mar 2024 14:05:12 +0100 Subject: [PATCH] fix: remove old block param --- relay_client/src/http.rs | 7 +------ relay_client/src/websocket.rs | 15 ++++----------- relay_rpc/src/rpc.rs | 10 ---------- relay_rpc/src/rpc/tests.rs | 18 +++--------------- 4 files changed, 8 insertions(+), 42 deletions(-) diff --git a/relay_client/src/http.rs b/relay_client/src/http.rs index 4e792fc..b2466e2 100644 --- a/relay_client/src/http.rs +++ b/relay_client/src/http.rs @@ -131,11 +131,7 @@ impl Client { /// Subscribes on topic to receive messages. The request is resolved /// optimistically as soon as the relay receives it. pub async fn subscribe(&self, topic: Topic) -> Response { - self.request(rpc::Subscribe { - topic, - block: false, - }) - .await + self.request(rpc::Subscribe { topic }).await } /// Subscribes on topic to receive messages. The request is resolved only @@ -245,7 +241,6 @@ impl Client { ) -> Response { self.request(rpc::BatchSubscribe { topics: topics.into(), - block: false, }) .await } diff --git a/relay_client/src/websocket.rs b/relay_client/src/websocket.rs index 9b02658..3a1fccc 100644 --- a/relay_client/src/websocket.rs +++ b/relay_client/src/websocket.rs @@ -127,6 +127,8 @@ pub trait ConnectionHandler: Send + 'static { fn outbound_error(&mut self, _error: ClientError) {} } +type SubscriptionResult = Result>; + /// The Relay WebSocket RPC client. /// /// This provides the high-level access to all of the available RPC methods. For @@ -174,10 +176,7 @@ impl Client { /// Subscribes on topic to receive messages. The request is resolved /// optimistically as soon as the relay receives it. pub fn subscribe(&self, topic: Topic) -> ResponseFuture { - let (request, response) = create_request(Subscribe { - topic, - block: false, - }); + let (request, response) = create_request(Subscribe { topic }); self.request(request); @@ -224,7 +223,6 @@ impl Client { pub fn batch_subscribe(&self, topics: impl Into>) -> ResponseFuture { let (request, response) = create_request(BatchSubscribe { topics: topics.into(), - block: false, }); self.request(request); @@ -239,12 +237,7 @@ impl Client { pub fn batch_subscribe_blocking( &self, topics: impl Into>, - ) -> impl Future< - Output = Result< - Vec>>, - Error, - >, - > { + ) -> impl Future>>> { let (request, response) = create_request(BatchSubscribeBlocking { topics: topics.into(), }); diff --git a/relay_rpc/src/rpc.rs b/relay_rpc/src/rpc.rs index 17db730..a50fc2a 100644 --- a/relay_rpc/src/rpc.rs +++ b/relay_rpc/src/rpc.rs @@ -222,11 +222,6 @@ pub enum SubscriptionError { pub struct Subscribe { /// The topic to subscribe to. pub topic: Topic, - - /// Whether to disable optimistic response. By default optimistic response - /// is enabled. - #[serde(default)] - pub block: bool, } impl ServiceRequest for Subscribe { @@ -347,11 +342,6 @@ pub struct FetchResponse { pub struct BatchSubscribe { /// The topics to subscribe to. pub topics: Vec, - - /// Whether to disable optimistic response. By default optimistic response - /// is enabled. - #[serde(default)] - pub block: bool, } impl BatchSubscribe { diff --git a/relay_rpc/src/rpc/tests.rs b/relay_rpc/src/rpc/tests.rs index c3c1c29..85395b9 100644 --- a/relay_rpc/src/rpc/tests.rs +++ b/relay_rpc/src/rpc/tests.rs @@ -31,7 +31,6 @@ fn subscribe() { 1659980684711969.into(), Params::Subscribe(Subscribe { topic: "c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9840".into(), - block: false, }), )); @@ -39,7 +38,7 @@ fn subscribe() { assert_eq!( &serialized, - r#"{"id":1659980684711969,"jsonrpc":"2.0","method":"irn_subscribe","params":{"topic":"c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9840","block":false}}"# + r#"{"id":1659980684711969,"jsonrpc":"2.0","method":"irn_subscribe","params":{"topic":"c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9840"}}"# ); let deserialized: Payload = serde_json::from_str(&serialized).unwrap(); @@ -208,7 +207,6 @@ fn deserialize_batch_methods() { Topic::from("c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9840"), Topic::from("c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9841") ], - block: false }) }) ); @@ -346,7 +344,6 @@ fn validation() { jsonrpc: jsonrpc.clone(), params: Params::Subscribe(Subscribe { topic: topic.clone(), - block: false, }), }; assert_eq!(request.validate(), Ok(())); @@ -357,7 +354,6 @@ fn validation() { jsonrpc: jsonrpc.clone(), params: Params::Subscribe(Subscribe { topic: Topic::from("invalid"), - block: false, }), }; assert_eq!(request.validate(), Err(PayloadError::InvalidTopic)); @@ -456,7 +452,6 @@ fn validation() { jsonrpc: jsonrpc.clone(), params: Params::BatchSubscribe(BatchSubscribe { topics: vec![topic.clone()], - block: false, }), }; assert_eq!(request.validate(), Ok(())); @@ -465,10 +460,7 @@ fn validation() { let request = Request { id, jsonrpc: jsonrpc.clone(), - params: Params::BatchSubscribe(BatchSubscribe { - topics: vec![], - block: false, - }), + params: Params::BatchSubscribe(BatchSubscribe { topics: vec![] }), }; assert_eq!(request.validate(), Err(PayloadError::BatchEmpty)); @@ -479,10 +471,7 @@ fn validation() { let request = Request { id, jsonrpc: jsonrpc.clone(), - params: Params::BatchSubscribe(BatchSubscribe { - topics, - block: false, - }), + params: Params::BatchSubscribe(BatchSubscribe { topics }), }; assert_eq!(request.validate(), Err(PayloadError::BatchLimitExceeded)); @@ -494,7 +483,6 @@ fn validation() { topics: vec![Topic::from( "c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c98401", )], - block: false, }), }; assert_eq!(request.validate(), Err(PayloadError::InvalidTopic));