mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Move state.rs under database module
The types in state are only used for the database
This commit is contained in:
parent
8c7964bfee
commit
b410de01df
@ -11,9 +11,8 @@ use crate::{
|
||||
},
|
||||
},
|
||||
bitcoin::EncryptedSignature,
|
||||
database::Database,
|
||||
database::{state::Swap, Database},
|
||||
network::request_response::AliceToBob,
|
||||
state::Swap,
|
||||
SwapAmounts,
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
@ -1,4 +1,8 @@
|
||||
use crate::{bob::event_loop::EventLoopHandle, database::Database, state, SwapAmounts};
|
||||
use crate::{
|
||||
bob::event_loop::EventLoopHandle,
|
||||
database::{state, Database},
|
||||
SwapAmounts,
|
||||
};
|
||||
use anyhow::{bail, Result};
|
||||
use async_recursion::async_recursion;
|
||||
use rand::{CryptoRng, RngCore};
|
||||
|
@ -1,9 +1,11 @@
|
||||
use crate::state::Swap;
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use state::Swap;
|
||||
use std::path::Path;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub mod state;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Database(sled::Db);
|
||||
|
||||
@ -82,7 +84,7 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::state::{Alice, AliceEndState, Bob, BobEndState};
|
||||
use crate::database::state::{Alice, AliceEndState, Bob, BobEndState};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -23,7 +23,6 @@ pub mod cli;
|
||||
pub mod database;
|
||||
pub mod monero;
|
||||
pub mod network;
|
||||
pub mod state;
|
||||
pub mod trace;
|
||||
|
||||
pub type Never = std::convert::Infallible;
|
||||
|
@ -25,10 +25,9 @@ use swap::{
|
||||
bitcoin, bob,
|
||||
bob::swap::BobState,
|
||||
cli::{Command, Options, Resume},
|
||||
database::Database,
|
||||
database::{state::Swap, Database},
|
||||
monero,
|
||||
network::transport::build,
|
||||
state::Swap,
|
||||
trace::init_tracing,
|
||||
SwapAmounts,
|
||||
};
|
||||
|
@ -111,9 +111,10 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
|
||||
|
||||
let alice_db = Database::open(alice_db_datadir.path()).unwrap();
|
||||
|
||||
let resume_state =
|
||||
if let swap::state::Swap::Alice(state) = alice_db.get_state(alice_swap_id).unwrap() {
|
||||
assert!(matches!(state, swap::state::Alice::EncSigLearned {..}));
|
||||
let resume_state = if let swap::database::state::Swap::Alice(state) =
|
||||
alice_db.get_state(alice_swap_id).unwrap()
|
||||
{
|
||||
assert!(matches!(state, swap::database::state::Alice::EncSigLearned {..}));
|
||||
state.into()
|
||||
} else {
|
||||
unreachable!()
|
||||
|
@ -114,9 +114,9 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
|
||||
|
||||
let bob_db = Database::open(bob_db_datadir.path()).unwrap();
|
||||
|
||||
let resume_state = if let swap::state::Swap::Bob(state) = bob_db.get_state(bob_swap_id).unwrap()
|
||||
{
|
||||
assert!(matches!(state, swap::state::Bob::EncSigSent {..}));
|
||||
let resume_state =
|
||||
if let swap::database::state::Swap::Bob(state) = bob_db.get_state(bob_swap_id).unwrap() {
|
||||
assert!(matches!(state, swap::database::state::Bob::EncSigSent {..}));
|
||||
state.into()
|
||||
} else {
|
||||
unreachable!()
|
||||
|
Loading…
Reference in New Issue
Block a user