Serve subscribed order book updates over a market WebSocket
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user