Skip to content

Commit 79a72ff

Browse files
authored
fix: support ids without leading 0x (#9)
This code change is hacky and not fully correct. The whole code needs to be refactored later to parse hex properly into 32-bytes array (as hermes) instead of relying on String
1 parent 1f3f3f6 commit 79a72ff

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

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.

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-stream"
3-
version = "0.1.7"
3+
version = "0.1.8"
44
edition = "2021"
55

66
[lib]

src/bin/websocket_server.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ async fn handle_client_message(addr: &str, text: &str, clients: &Clients) -> Res
217217
async fn handle_subscribe(addr: &str, ids: Vec<String>, clients: &Clients) -> ServerResponse {
218218
let mut clients = clients.lock().await;
219219
if let Some((subscriptions, _)) = clients.get_mut(addr) {
220-
for hex_id in ids {
220+
for mut hex_id in ids {
221+
if !hex_id.starts_with("0x") {
222+
hex_id = format!("0x{}", hex_id);
223+
}
221224
subscriptions.insert(hex_id.clone());
222225
debug!("Client {} subscribed to feed ID: {}", addr, hex_id);
223226
}

0 commit comments

Comments
 (0)