Replace swap recover terminology with resume

This commit is contained in:
Franck Royer 2020-12-15 11:52:00 +11:00
parent 8cc470a80e
commit 5ba830f3bf
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
6 changed files with 7 additions and 11 deletions

View File

@ -41,8 +41,6 @@ trait Rng: RngCore + CryptoRng + Send {}
impl<T> Rng for T where T: RngCore + CryptoRng + Send {} impl<T> Rng for T where T: RngCore + CryptoRng + Send {}
// The same data structure is used for swap execution and recovery.
// This allows for a seamless transition from a failed swap to recovery.
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum AliceState { pub enum AliceState {
Started { Started {
@ -128,7 +126,7 @@ impl From<&AliceState> for state::Alice {
AliceState::T1Expired { state3 } => Alice::T1Expired(state3.clone()), AliceState::T1Expired { state3 } => Alice::T1Expired(state3.clone()),
AliceState::Punished => Alice::SwapComplete, AliceState::Punished => Alice::SwapComplete,
AliceState::SafelyAborted => Alice::SwapComplete, AliceState::SafelyAborted => Alice::SwapComplete,
// TODO: Potentially add support to recover swaps that are not Negotiated // TODO: Potentially add support to resume swaps that are not Negotiated
AliceState::Started { .. } => { AliceState::Started { .. } => {
panic!("Alice attempted to save swap before being negotiated") panic!("Alice attempted to save swap before being negotiated")
} }
@ -235,7 +233,7 @@ pub async fn swap(
.await .await
} }
pub async fn recover( pub async fn resume_from_database(
event_loop_handle: EventLoopHandle, event_loop_handle: EventLoopHandle,
bitcoin_wallet: Arc<crate::bitcoin::Wallet>, bitcoin_wallet: Arc<crate::bitcoin::Wallet>,
monero_wallet: Arc<crate::monero::Wallet>, monero_wallet: Arc<crate::monero::Wallet>,

View File

@ -222,7 +222,7 @@ async fn main() -> Result<()> {
// Print the table to stdout // Print the table to stdout
table.printstd(); table.printstd();
} }
Options::Recover { .. } => todo!("implement this"), Options::Resume { .. } => todo!("implement this"),
} }
Ok(()) Ok(())

View File

@ -17,8 +17,6 @@ use xmr_btc::{
Epoch, Epoch,
}; };
// The same data structure is used for swap execution and recovery.
// This allows for a seamless transition from a failed swap to recovery.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum BobState { pub enum BobState {
Started { Started {
@ -124,7 +122,7 @@ where
.await .await
} }
pub async fn recover<R>( pub async fn resume_from_database<R>(
event_loop_handle: EventLoopHandle, event_loop_handle: EventLoopHandle,
db: Database, db: Database,
bitcoin_wallet: Arc<crate::bitcoin::Wallet>, bitcoin_wallet: Arc<crate::bitcoin::Wallet>,

View File

@ -64,7 +64,7 @@ pub enum Options {
receive_monero: xmr_btc::monero::Amount, receive_monero: xmr_btc::monero::Amount,
}, },
History, History,
Recover { Resume {
#[structopt(required = true)] #[structopt(required = true)]
swap_id: Uuid, swap_id: Uuid,

View File

@ -114,7 +114,7 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
testutils::init_alice_event_loop(alice_multiaddr); testutils::init_alice_event_loop(alice_multiaddr);
let _alice_swarm_fut = tokio::spawn(async move { event_loop_after_restart.run().await }); let _alice_swarm_fut = tokio::spawn(async move { event_loop_after_restart.run().await });
let alice_state = alice::swap::recover( let alice_state = alice::swap::resume_from_database(
event_loop_handle_after_restart, event_loop_handle_after_restart,
alice_btc_wallet, alice_btc_wallet,
alice_xmr_wallet, alice_xmr_wallet,

View File

@ -114,7 +114,7 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
testutils::init_bob_event_loop(); testutils::init_bob_event_loop();
let _alice_swarm_fut = tokio::spawn(async move { event_loop_after_restart.run().await }); let _alice_swarm_fut = tokio::spawn(async move { event_loop_after_restart.run().await });
let alice_state = bob::swap::recover( let alice_state = bob::swap::resume_from_database(
event_loop_handle_after_restart, event_loop_handle_after_restart,
bob_db, bob_db,
bob_btc_wallet, bob_btc_wallet,