Serve subscribed order book updates over a market WebSocket

This commit is contained in:
2026-12-03 07:35:08 +08:00
parent 6b50266300
commit e80e52275c
13 changed files with 675 additions and 20 deletions
+6 -1
View File
@@ -94,8 +94,13 @@ pub(crate) fn read(tx: &Transaction, books: &mut Books, token: &str) -> Result<V
Ok(serde_json::to_value(build(tx, books, token)?)?)
}
pub(crate) fn event(tx: &Transaction, books: &Books, token: &str) -> Result<Value> {
pub(crate) fn event(tx: &Transaction, books: &Books, token: &str, raw: bool) -> Result<Value> {
let s = build(tx, books, token)?;
if raw {
let mut frame = serde_json::to_value(s)?;
frame["event_type"] = json!("book");
return Ok(frame);
}
let stamp: String = tx.query_row(
"SELECT strftime('%Y-%m-%dT%H:%M:%f000Z',?1/1000.0,'unixepoch')",
[&s.timestamp],