Model sports events and market rules and persist trade price history
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
mod catalog;
|
||||
mod validation;
|
||||
use validation::identifier;
|
||||
mod book;
|
||||
@@ -29,6 +30,13 @@ impl Exchange {
|
||||
}
|
||||
|
||||
pub fn execute(&mut self, payload: Value) -> Result<Value> {
|
||||
if matches!(payload["op"].as_str(), Some("catalog" | "history")) {
|
||||
let query: catalog::Query = serde_json::from_value(payload)?;
|
||||
let tx = self.db.transaction()?;
|
||||
let value = query.read(&tx)?;
|
||||
tx.commit()?;
|
||||
return Ok(value);
|
||||
}
|
||||
if payload == json!({"op":"state"}) {
|
||||
let tx = self.db.transaction()?;
|
||||
let mut state = Map::new();
|
||||
|
||||
Reference in New Issue
Block a user