This commit is contained in:
2026-07-29 06:57:25 +02:00
parent 90d3c59ff4
commit f3406c7b97
7 changed files with 62 additions and 51 deletions
Generated
+2
View File
@@ -3947,6 +3947,7 @@ version = "0.1.0-alpha.0"
dependencies = [ dependencies = [
"hypersdk", "hypersdk",
"postcard", "postcard",
"rust_decimal",
"serde", "serde",
"tokio", "tokio",
] ]
@@ -3963,6 +3964,7 @@ dependencies = [
"pulse-sdk", "pulse-sdk",
"pulse-ui", "pulse-ui",
"rand 0.8.7", "rand 0.8.7",
"rust_decimal",
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
+2
View File
@@ -11,6 +11,7 @@ hypersdk = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
anyhow = { workspace = true } anyhow = { workspace = true }
postcard = { workspace = true } postcard = { workspace = true }
rust_decimal = { workspace = true }
tokio = { workspace = true, features = [ tokio = { workspace = true, features = [
"rt-multi-thread", "rt-multi-thread",
"macros", "macros",
@@ -29,6 +30,7 @@ toml = "1.1.3"
members = ["pulse-ui", "pulse-sdk"] members = ["pulse-ui", "pulse-sdk"]
[workspace.dependencies] [workspace.dependencies]
rust_decimal = { version = "1.39", features = ["serde-str"] }
postcard = { version = "1.1.3", features = ["alloc"] } postcard = { version = "1.1.3", features = ["alloc"] }
pulse-ui = { path = "pulse-ui", version = "0.1.0-alpha.0" } pulse-ui = { path = "pulse-ui", version = "0.1.0-alpha.0" }
pulse-sdk = { path = "pulse-sdk", version = "0.1.0-alpha.0" } pulse-sdk = { path = "pulse-sdk", version = "0.1.0-alpha.0" }
+2 -1
View File
@@ -7,4 +7,5 @@ edition = "2024"
serde = { workspace = true } serde = { workspace = true }
hypersdk = { workspace = true } hypersdk = { workspace = true }
postcard = { workspace = true } postcard = { workspace = true }
tokio = { workspace = true, features = ["io-std"]} tokio = { workspace = true, features = ["io-std"] }
rust_decimal = { workspace = true }
+1 -1
View File
@@ -1,4 +1,4 @@
use hypersdk::Decimal; use rust_decimal::Decimal;
use crate::units::{Direction, Symbol, USD}; use crate::units::{Direction, Symbol, USD};
+1 -1
View File
@@ -1,4 +1,4 @@
use hypersdk::Decimal; use rust_decimal::Decimal;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Symbol(pub String); pub struct Symbol(pub String);
+1 -1
View File
@@ -1,4 +1,4 @@
use hypersdk::Decimal; use rust_decimal::Decimal;
use pulse_sdk::prelude::*; use pulse_sdk::prelude::*;
use serde_json::Value; use serde_json::Value;
use std::collections::HashMap; use std::collections::HashMap;
+53 -47
View File
@@ -53,16 +53,22 @@ impl TerminalClient {
let status = app.status.clone(); let status = app.status.clone();
let inspect = app.inspect.clone(); let inspect = app.inspect.clone();
tokio::spawn(Self::run_client( tokio::spawn(async {
reader, if let Err(v) = Self::run_client(
watch_list, reader,
active_positions, watch_list,
logs, active_positions,
signals, logs,
market_overview, signals,
status, market_overview,
inspect, status,
)); inspect,
)
.await
{
panic!("{v}")
}
});
app.sock = Some(self); app.sock = Some(self);
@@ -80,55 +86,55 @@ impl TerminalClient {
status: State<Option<Status>>, status: State<Option<Status>>,
inspect: State<InspectTarget>, inspect: State<InspectTarget>,
) -> tokio::io::Result<()> { ) -> tokio::io::Result<()> {
let mut len_buf = [0u8; size_of::<usize>()]; loop {
reader let mut len_buf = [0u8; size_of::<usize>()];
.read_exact(&mut len_buf) reader
.await .read_exact(&mut len_buf)
.expect("Failed to get header length"); .await
.expect("Failed to get header length");
let len = usize::from_le_bytes(len_buf); let len = usize::from_le_bytes(len_buf);
let mut buffer = vec![0u8; len]; let mut buffer = vec![0u8; len];
reader reader
.read_exact(&mut buffer) .read_exact(&mut buffer)
.await .await
.expect("Failed to read socket"); .expect("Failed to read socket");
match map_postcard_err(postcard::from_bytes(&buffer))? { match map_postcard_err(postcard::from_bytes(&buffer))? {
TerminalServerMessage::WatchListUpdated(v) => { TerminalServerMessage::WatchListUpdated(v) => {
*watch_list.lock().await = v; *watch_list.lock().await = v;
} }
TerminalServerMessage::PositionsUpdated(v) => { TerminalServerMessage::PositionsUpdated(v) => {
*active_positions.lock().await = v; *active_positions.lock().await = v;
} }
TerminalServerMessage::StrategyUpdated(v) => { TerminalServerMessage::StrategyUpdated(v) => {
*market_overview.lock().await = Some(v); *market_overview.lock().await = Some(v);
} }
TerminalServerMessage::SignalsUpdated(v) => { TerminalServerMessage::SignalsUpdated(v) => {
*signals.lock().await = v; *signals.lock().await = v;
} }
TerminalServerMessage::Inspect(v) => { TerminalServerMessage::Inspect(v) => {
*inspect.lock().await = v; *inspect.lock().await = v;
} }
TerminalServerMessage::StatusUpdated(v) => { TerminalServerMessage::StatusUpdated(v) => {
*status.lock().await = Some(v); *status.lock().await = Some(v);
} }
TerminalServerMessage::SetLogs(v) => { TerminalServerMessage::SetLogs(v) => {
*logs.lock().await = v; *logs.lock().await = v;
} }
TerminalServerMessage::AddLog(v) => { TerminalServerMessage::AddLog(v) => {
logs.lock().await.push(v); logs.lock().await.push(v);
}
} }
} }
Ok(())
} }
} }