Browse Source

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
Darun Seethammagari 9 months ago
parent
commit
5d8e1bb43b
3 changed files with 7 additions and 8 deletions
  1. 1 1
      lazer/Cargo.lock
  2. 1 1
      lazer/sdk/rust/protocol/Cargo.toml
  3. 5 6
      lazer/sdk/rust/protocol/src/router.rs

+ 1 - 1
lazer/Cargo.lock

@@ -3698,7 +3698,7 @@ dependencies = [
 
 [[package]]
 name = "pyth-lazer-protocol"
-version = "0.3.3"
+version = "0.4.0"
 dependencies = [
  "alloy-primitives",
  "anyhow",

+ 1 - 1
lazer/sdk/rust/protocol/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "pyth-lazer-protocol"
-version = "0.3.3"
+version = "0.4.0"
 edition = "2021"
 description = "Pyth Lazer SDK - protocol types."
 license = "Apache-2.0"

+ 5 - 6
lazer/sdk/rust/protocol/src/router.rs

@@ -163,7 +163,6 @@ pub enum JsonBinaryEncoding {
 
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub enum Channel {
-    RealTime,
     FixedRate(FixedRate),
 }
 
@@ -173,8 +172,10 @@ impl Serialize for Channel {
         S: serde::Serializer,
     {
         match self {
-            Channel::RealTime => serializer.serialize_str("real_time"),
             Channel::FixedRate(fixed_rate) => {
+                if *fixed_rate == FixedRate::MIN {
+                    return serializer.serialize_str("real_time");
+                }
                 serializer.serialize_str(&format!("fixed_rate@{}ms", fixed_rate.value_ms()))
             }
         }
@@ -184,16 +185,14 @@ impl Serialize for Channel {
 mod channel_ids {
     use super::ChannelId;
 
-    pub const REAL_TIME: ChannelId = ChannelId(1);
+    pub const FIXED_RATE_1: ChannelId = ChannelId(1);
     pub const FIXED_RATE_50: ChannelId = ChannelId(2);
     pub const FIXED_RATE_200: ChannelId = ChannelId(3);
-    pub const FIXED_RATE_1: ChannelId = ChannelId(4);
 }
 
 impl Channel {
     pub fn id(&self) -> ChannelId {
         match self {
-            Channel::RealTime => channel_ids::REAL_TIME,
             Channel::FixedRate(fixed_rate) => match fixed_rate.value_ms() {
                 1 => channel_ids::FIXED_RATE_1,
                 50 => channel_ids::FIXED_RATE_50,
@@ -213,7 +212,7 @@ fn id_supports_all_fixed_rates() {
 
 fn parse_channel(value: &str) -> Option<Channel> {
     if value == "real_time" {
-        Some(Channel::RealTime)
+        Some(Channel::FixedRate(FixedRate::MIN))
     } else if let Some(rest) = value.strip_prefix("fixed_rate@") {
         let ms_value = rest.strip_suffix("ms")?;
         Some(Channel::FixedRate(FixedRate::from_ms(