Route orders and market data by stable outcome asset IDs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
mod account_orders;
|
||||
mod assets;
|
||||
mod catalog;
|
||||
mod expiry;
|
||||
mod validation;
|
||||
@@ -35,10 +36,12 @@ impl Exchange {
|
||||
pub fn execute(&mut self, payload: Value) -> Result<Value> {
|
||||
if matches!(
|
||||
payload["op"].as_str(),
|
||||
Some("catalog" | "history" | "quote" | "book" | "open_orders" | "positions")
|
||||
Some("assets" | "catalog" | "history" | "quote" | "book" | "open_orders" | "positions")
|
||||
) {
|
||||
let query: catalog::Query = serde_json::from_value(payload)?;
|
||||
let tx = expiry::transaction(&self.db, TransactionBehavior::Deferred)?;
|
||||
let mut request = payload;
|
||||
assets::resolve(&tx, &mut request)?;
|
||||
let query: catalog::Query = serde_json::from_value(request)?;
|
||||
let value = query.read(&tx)?;
|
||||
tx.commit()?;
|
||||
return Ok(value);
|
||||
@@ -98,6 +101,7 @@ impl Exchange {
|
||||
body.as_object_mut()
|
||||
.context("expected object")?
|
||||
.remove("id");
|
||||
assets::resolve(&tx, &mut body)?;
|
||||
let command = serde_json::from_value(body)?;
|
||||
let external = self.books.changes(&tx)?;
|
||||
self.books.apply(external);
|
||||
|
||||
Reference in New Issue
Block a user