Skip to content

Commit 243ca2d

Browse files
authored
fix: remove old block param (#74)
1 parent 7664418 commit 243ca2d

File tree

4 files changed

+8
-42
lines changed

4 files changed

+8
-42
lines changed

relay_client/src/http.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,7 @@ impl Client {
131131
/// Subscribes on topic to receive messages. The request is resolved
132132
/// optimistically as soon as the relay receives it.
133133
pub async fn subscribe(&self, topic: Topic) -> Response<rpc::Subscribe> {
134-
self.request(rpc::Subscribe {
135-
topic,
136-
block: false,
137-
})
138-
.await
134+
self.request(rpc::Subscribe { topic }).await
139135
}
140136

141137
/// Subscribes on topic to receive messages. The request is resolved only
@@ -245,7 +241,6 @@ impl Client {
245241
) -> Response<rpc::BatchSubscribe> {
246242
self.request(rpc::BatchSubscribe {
247243
topics: topics.into(),
248-
block: false,
249244
})
250245
.await
251246
}

relay_client/src/websocket.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ pub trait ConnectionHandler: Send + 'static {
127127
fn outbound_error(&mut self, _error: ClientError) {}
128128
}
129129

130+
type SubscriptionResult<T> = Result<T, Error<SubscriptionError>>;
131+
130132
/// The Relay WebSocket RPC client.
131133
///
132134
/// This provides the high-level access to all of the available RPC methods. For
@@ -174,10 +176,7 @@ impl Client {
174176
/// Subscribes on topic to receive messages. The request is resolved
175177
/// optimistically as soon as the relay receives it.
176178
pub fn subscribe(&self, topic: Topic) -> ResponseFuture<Subscribe> {
177-
let (request, response) = create_request(Subscribe {
178-
topic,
179-
block: false,
180-
});
179+
let (request, response) = create_request(Subscribe { topic });
181180

182181
self.request(request);
183182

@@ -224,7 +223,6 @@ impl Client {
224223
pub fn batch_subscribe(&self, topics: impl Into<Vec<Topic>>) -> ResponseFuture<BatchSubscribe> {
225224
let (request, response) = create_request(BatchSubscribe {
226225
topics: topics.into(),
227-
block: false,
228226
});
229227

230228
self.request(request);
@@ -239,12 +237,7 @@ impl Client {
239237
pub fn batch_subscribe_blocking(
240238
&self,
241239
topics: impl Into<Vec<Topic>>,
242-
) -> impl Future<
243-
Output = Result<
244-
Vec<Result<SubscriptionId, Error<SubscriptionError>>>,
245-
Error<SubscriptionError>,
246-
>,
247-
> {
240+
) -> impl Future<Output = SubscriptionResult<Vec<SubscriptionResult<SubscriptionId>>>> {
248241
let (request, response) = create_request(BatchSubscribeBlocking {
249242
topics: topics.into(),
250243
});

relay_rpc/src/rpc.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ pub enum SubscriptionError {
222222
pub struct Subscribe {
223223
/// The topic to subscribe to.
224224
pub topic: Topic,
225-
226-
/// Whether to disable optimistic response. By default optimistic response
227-
/// is enabled.
228-
#[serde(default)]
229-
pub block: bool,
230225
}
231226

232227
impl ServiceRequest for Subscribe {
@@ -347,11 +342,6 @@ pub struct FetchResponse {
347342
pub struct BatchSubscribe {
348343
/// The topics to subscribe to.
349344
pub topics: Vec<Topic>,
350-
351-
/// Whether to disable optimistic response. By default optimistic response
352-
/// is enabled.
353-
#[serde(default)]
354-
pub block: bool,
355345
}
356346

357347
impl BatchSubscribe {

relay_rpc/src/rpc/tests.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,14 @@ fn subscribe() {
3131
1659980684711969.into(),
3232
Params::Subscribe(Subscribe {
3333
topic: "c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9840".into(),
34-
block: false,
3534
}),
3635
));
3736

3837
let serialized = serde_json::to_string(&payload).unwrap();
3938

4039
assert_eq!(
4140
&serialized,
42-
r#"{"id":1659980684711969,"jsonrpc":"2.0","method":"irn_subscribe","params":{"topic":"c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9840","block":false}}"#
41+
r#"{"id":1659980684711969,"jsonrpc":"2.0","method":"irn_subscribe","params":{"topic":"c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9840"}}"#
4342
);
4443

4544
let deserialized: Payload = serde_json::from_str(&serialized).unwrap();
@@ -208,7 +207,6 @@ fn deserialize_batch_methods() {
208207
Topic::from("c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9840"),
209208
Topic::from("c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c9841")
210209
],
211-
block: false
212210
})
213211
})
214212
);
@@ -346,7 +344,6 @@ fn validation() {
346344
jsonrpc: jsonrpc.clone(),
347345
params: Params::Subscribe(Subscribe {
348346
topic: topic.clone(),
349-
block: false,
350347
}),
351348
};
352349
assert_eq!(request.validate(), Ok(()));
@@ -357,7 +354,6 @@ fn validation() {
357354
jsonrpc: jsonrpc.clone(),
358355
params: Params::Subscribe(Subscribe {
359356
topic: Topic::from("invalid"),
360-
block: false,
361357
}),
362358
};
363359
assert_eq!(request.validate(), Err(PayloadError::InvalidTopic));
@@ -456,7 +452,6 @@ fn validation() {
456452
jsonrpc: jsonrpc.clone(),
457453
params: Params::BatchSubscribe(BatchSubscribe {
458454
topics: vec![topic.clone()],
459-
block: false,
460455
}),
461456
};
462457
assert_eq!(request.validate(), Ok(()));
@@ -465,10 +460,7 @@ fn validation() {
465460
let request = Request {
466461
id,
467462
jsonrpc: jsonrpc.clone(),
468-
params: Params::BatchSubscribe(BatchSubscribe {
469-
topics: vec![],
470-
block: false,
471-
}),
463+
params: Params::BatchSubscribe(BatchSubscribe { topics: vec![] }),
472464
};
473465
assert_eq!(request.validate(), Err(PayloadError::BatchEmpty));
474466

@@ -479,10 +471,7 @@ fn validation() {
479471
let request = Request {
480472
id,
481473
jsonrpc: jsonrpc.clone(),
482-
params: Params::BatchSubscribe(BatchSubscribe {
483-
topics,
484-
block: false,
485-
}),
474+
params: Params::BatchSubscribe(BatchSubscribe { topics }),
486475
};
487476
assert_eq!(request.validate(), Err(PayloadError::BatchLimitExceeded));
488477

@@ -494,7 +483,6 @@ fn validation() {
494483
topics: vec![Topic::from(
495484
"c4163cf65859106b3f5435fc296e7765411178ed452d1c30337a6230138c98401",
496485
)],
497-
block: false,
498486
}),
499487
};
500488
assert_eq!(request.validate(), Err(PayloadError::InvalidTopic));

0 commit comments

Comments
 (0)