Group independent binary markets under discoverable topic events

This commit is contained in:
2026-12-03 04:36:46 +08:00
parent ea6383f089
commit dd3e563a48
10 changed files with 278 additions and 64 deletions
+1 -32
View File
@@ -17,38 +17,7 @@ pub(crate) fn apply(tx: &Transaction, books: &Books, command: Command) -> Result
tx.execute("INSERT INTO accounts VALUES(?,?)", params![account, cents])?;
Ok(json!({"funded":cents}))
}
Command::Event {
event,
title,
sport,
competition,
home,
away,
scheduled_at_ms,
} => {
identifier(&event)?;
ensure!(
scheduled_at_ms >= 0
&& home.trim() != away.trim()
&& [&title, &sport, &competition, &home, &away]
.iter()
.all(|s| !s.trim().is_empty()),
"invalid event"
);
tx.execute(
"INSERT INTO events VALUES(?,?,?,?,?,?,?)",
params![
event,
title,
sport,
competition,
home,
away,
scheduled_at_ms
],
)?;
Ok(json!({"event":event}))
}
Command::Event(event) => event.save(tx),
Command::List {
market,
rules,