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
+10
View File
@@ -42,6 +42,9 @@ use rusqlite::{params, types::ValueRef, Connection, OptionalExtension, Transacti
use serde_json::{json, Map, Value};
use std::{path::Path, time::Duration};
pub use assets::parse_id as parse_asset_id;
pub use depth_feed::MarketPage;
pub struct Exchange {
db: Connection,
books: Books,
@@ -107,6 +110,13 @@ impl Exchange {
Ok(())
}
pub fn market_stream_page(&mut self, market: &str, after: Option<i64>) -> Result<MarketPage> {
let tx = expiry::transaction(&self.db, TransactionBehavior::Deferred)?;
let page = depth_feed::Request::wire(market, after).page(&tx, &mut self.books, true)?;
tx.commit()?;
Ok(page)
}
pub fn execute(&mut self, mut payload: Value) -> Result<Value> {
if payload["op"].as_str() == Some("heartbeat") {
payload