|
|
|
@ -5,7 +5,7 @@ use anyhow::{anyhow, Context, Result};
|
|
|
|
|
use async_trait::async_trait;
|
|
|
|
|
use libp2p::{Multiaddr, PeerId};
|
|
|
|
|
use sqlx::sqlite::Sqlite;
|
|
|
|
|
use sqlx::{Pool, Row, SqlitePool};
|
|
|
|
|
use sqlx::{Pool, SqlitePool};
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
use std::str::FromStr;
|
|
|
|
@ -276,21 +276,21 @@ impl Database for SqliteDatabase {
|
|
|
|
|
|
|
|
|
|
// TODO: We should use query! instead of query here to allow for at-compile-time validation
|
|
|
|
|
// I didn't manage to generate the mappings for the query! macro because of problems with sqlx-cli
|
|
|
|
|
let rows = sqlx::query(
|
|
|
|
|
let rows = sqlx::query!(
|
|
|
|
|
r#"
|
|
|
|
|
SELECT state
|
|
|
|
|
FROM swap_states
|
|
|
|
|
WHERE swap_id = ?
|
|
|
|
|
"#,
|
|
|
|
|
swap_id
|
|
|
|
|
)
|
|
|
|
|
.bind(swap_id)
|
|
|
|
|
.fetch_all(&mut conn)
|
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
let result = rows
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|row| {
|
|
|
|
|
let state_str: &str = row.try_get("state")?;
|
|
|
|
|
let state_str: &str = &row.state;
|
|
|
|
|
|
|
|
|
|
let state = match serde_json::from_str::<Swap>(state_str) {
|
|
|
|
|
Ok(a) => Ok(State::from(a)),
|
|
|
|
|