Skip to content

Commit 5d8e1bb

Browse files
authored
feat: Remove Real Time Channel (#2304)
* Remove real time channel * Update to new version * Change fixed rate to id 1 and retain real time parsing to fixed rate * Serialize min fixed rate to real time
1 parent bf4375e commit 5d8e1bb

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

lazer/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/sdk/rust/protocol/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-protocol"
3-
version = "0.3.3"
3+
version = "0.4.0"
44
edition = "2021"
55
description = "Pyth Lazer SDK - protocol types."
66
license = "Apache-2.0"

lazer/sdk/rust/protocol/src/router.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ pub enum JsonBinaryEncoding {
163163

164164
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
165165
pub enum Channel {
166-
RealTime,
167166
FixedRate(FixedRate),
168167
}
169168

@@ -173,8 +172,10 @@ impl Serialize for Channel {
173172
S: serde::Serializer,
174173
{
175174
match self {
176-
Channel::RealTime => serializer.serialize_str("real_time"),
177175
Channel::FixedRate(fixed_rate) => {
176+
if *fixed_rate == FixedRate::MIN {
177+
return serializer.serialize_str("real_time");
178+
}
178179
serializer.serialize_str(&format!("fixed_rate@{}ms", fixed_rate.value_ms()))
179180
}
180181
}
@@ -184,16 +185,14 @@ impl Serialize for Channel {
184185
mod channel_ids {
185186
use super::ChannelId;
186187

187-
pub const REAL_TIME: ChannelId = ChannelId(1);
188+
pub const FIXED_RATE_1: ChannelId = ChannelId(1);
188189
pub const FIXED_RATE_50: ChannelId = ChannelId(2);
189190
pub const FIXED_RATE_200: ChannelId = ChannelId(3);
190-
pub const FIXED_RATE_1: ChannelId = ChannelId(4);
191191
}
192192

193193
impl Channel {
194194
pub fn id(&self) -> ChannelId {
195195
match self {
196-
Channel::RealTime => channel_ids::REAL_TIME,
197196
Channel::FixedRate(fixed_rate) => match fixed_rate.value_ms() {
198197
1 => channel_ids::FIXED_RATE_1,
199198
50 => channel_ids::FIXED_RATE_50,
@@ -213,7 +212,7 @@ fn id_supports_all_fixed_rates() {
213212

214213
fn parse_channel(value: &str) -> Option<Channel> {
215214
if value == "real_time" {
216-
Some(Channel::RealTime)
215+
Some(Channel::FixedRate(FixedRate::MIN))
217216
} else if let Some(rest) = value.strip_prefix("fixed_rate@") {
218217
let ms_value = rest.strip_suffix("ms")?;
219218
Some(Channel::FixedRate(FixedRate::from_ms(

0 commit comments

Comments
 (0)