Skip to content

Commit bf4375e

Browse files
authored
feat(lazer-protocol): Add fixed rate 1ms (#2303)
1 parent 71f6366 commit bf4375e

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
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.2"
3+
version = "0.3.3"
44
edition = "2021"
55
description = "Pyth Lazer SDK - protocol types."
66
license = "Apache-2.0"

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,15 @@ mod channel_ids {
187187
pub const REAL_TIME: ChannelId = ChannelId(1);
188188
pub const FIXED_RATE_50: ChannelId = ChannelId(2);
189189
pub const FIXED_RATE_200: ChannelId = ChannelId(3);
190+
pub const FIXED_RATE_1: ChannelId = ChannelId(4);
190191
}
191192

192193
impl Channel {
193194
pub fn id(&self) -> ChannelId {
194195
match self {
195196
Channel::RealTime => channel_ids::REAL_TIME,
196197
Channel::FixedRate(fixed_rate) => match fixed_rate.value_ms() {
198+
1 => channel_ids::FIXED_RATE_1,
197199
50 => channel_ids::FIXED_RATE_50,
198200
200 => channel_ids::FIXED_RATE_200,
199201
_ => panic!("unknown channel: {self:?}"),
@@ -242,7 +244,7 @@ impl FixedRate {
242244
// - Values are sorted.
243245
// - 1 second contains a whole number of each interval.
244246
// - all intervals are divisable by the smallest interval.
245-
pub const ALL: [Self; 2] = [Self { ms: 50 }, Self { ms: 200 }];
247+
pub const ALL: [Self; 3] = [Self { ms: 1 }, Self { ms: 50 }, Self { ms: 200 }];
246248
pub const MIN: Self = Self::ALL[0];
247249

248250
pub fn from_ms(value: u32) -> Option<Self> {
@@ -270,7 +272,7 @@ fn fixed_rate_values() {
270272
"1 s must contain whole number of intervals"
271273
);
272274
assert!(
273-
value.ms % FixedRate::MIN.ms == 0,
275+
value.value_us() % FixedRate::MIN.value_us() == 0,
274276
"the interval's borders must be a subset of the minimal interval's borders"
275277
);
276278
}

0 commit comments

Comments
 (0)