Przeglądaj źródła

feat(lazer-protocol): Add fixed rate 1ms (#2303)

Darun Seethammagari 9 miesięcy temu
rodzic
commit
bf4375e5da

+ 1 - 1
lazer/Cargo.lock

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

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

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

+ 4 - 2
lazer/sdk/rust/protocol/src/router.rs

@@ -187,6 +187,7 @@ mod channel_ids {
     pub const REAL_TIME: 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 {
@@ -194,6 +195,7 @@ impl Channel {
         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,
                 200 => channel_ids::FIXED_RATE_200,
                 _ => panic!("unknown channel: {self:?}"),
@@ -242,7 +244,7 @@ impl FixedRate {
     // - Values are sorted.
     // - 1 second contains a whole number of each interval.
     // - all intervals are divisable by the smallest interval.
-    pub const ALL: [Self; 2] = [Self { ms: 50 }, Self { ms: 200 }];
+    pub const ALL: [Self; 3] = [Self { ms: 1 }, Self { ms: 50 }, Self { ms: 200 }];
     pub const MIN: Self = Self::ALL[0];
 
     pub fn from_ms(value: u32) -> Option<Self> {
@@ -270,7 +272,7 @@ fn fixed_rate_values() {
             "1 s must contain whole number of intervals"
         );
         assert!(
-            value.ms % FixedRate::MIN.ms == 0,
+            value.value_us() % FixedRate::MIN.value_us() == 0,
             "the interval's borders must be a subset of the minimal interval's borders"
         );
     }