Remove unused clone from states

This commit is contained in:
rishflab 2020-10-08 11:21:21 +11:00
parent d01c05e5f5
commit 213034dc1f
3 changed files with 13 additions and 17 deletions

View File

@ -17,7 +17,6 @@ monero = "0.9"
rand = "0.7" rand = "0.7"
sha2 = "0.9" sha2 = "0.9"
thiserror = "1" thiserror = "1"
tokio = { version = "0.2", default-features = false, features = ["time"] }
tracing = "0.1" tracing = "0.1"
[dev-dependencies] [dev-dependencies]

View File

@ -76,7 +76,7 @@ pub async fn next_state<
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub enum State { pub enum State {
State0(State0), State0(State0),
State1(State1), State1(State1),
@ -172,7 +172,7 @@ impl State {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State0 { pub struct State0 {
a: bitcoin::SecretKey, a: bitcoin::SecretKey,
s_a: cross_curve_dleq::Scalar, s_a: cross_curve_dleq::Scalar,
@ -258,7 +258,7 @@ impl State0 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State1 { pub struct State1 {
a: bitcoin::SecretKey, a: bitcoin::SecretKey,
B: bitcoin::PublicKey, B: bitcoin::PublicKey,
@ -296,7 +296,7 @@ impl State1 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State2 { pub struct State2 {
a: bitcoin::SecretKey, a: bitcoin::SecretKey,
B: bitcoin::PublicKey, B: bitcoin::PublicKey,
@ -371,7 +371,7 @@ impl State2 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State3 { pub struct State3 {
a: bitcoin::SecretKey, a: bitcoin::SecretKey,
B: bitcoin::PublicKey, B: bitcoin::PublicKey,
@ -424,7 +424,7 @@ impl State3 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State4 { pub struct State4 {
a: bitcoin::SecretKey, a: bitcoin::SecretKey,
B: bitcoin::PublicKey, B: bitcoin::PublicKey,
@ -527,7 +527,7 @@ impl State4 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State5 { pub struct State5 {
a: bitcoin::SecretKey, a: bitcoin::SecretKey,
B: bitcoin::PublicKey, B: bitcoin::PublicKey,
@ -618,7 +618,7 @@ impl State5 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State6 { pub struct State6 {
a: bitcoin::SecretKey, a: bitcoin::SecretKey,
B: bitcoin::PublicKey, B: bitcoin::PublicKey,

View File

@ -58,16 +58,13 @@ pub async fn next_state<
} }
State::State3(state3) => { State::State3(state3) => {
let message2: alice::Message2 = transport.receive_message().await?.try_into()?; let message2: alice::Message2 = transport.receive_message().await?.try_into()?;
let state4 = state3.watch_for_lock_xmr(monero_wallet, message2).await?; let state4 = state3.watch_for_lock_xmr(monero_wallet, message2).await?;
tracing::info!("bob has seen that alice has locked xmr"); tracing::info!("bob has seen that alice has locked xmr");
Ok(state4.into()) Ok(state4.into())
} }
State::State4(state4) => { State::State4(state4) => {
transport.send_message(state4.next_message().into()).await?; transport.send_message(state4.next_message().into()).await?;
tracing::info!("bob is watching for redeem_btc"); tracing::info!("bob is watching for redeem_btc");
tokio::time::delay_for(std::time::Duration::new(5, 0)).await;
let state5 = state4.watch_for_redeem_btc(bitcoin_wallet).await?; let state5 = state4.watch_for_redeem_btc(bitcoin_wallet).await?;
tracing::info!("bob has seen that alice has redeemed btc"); tracing::info!("bob has seen that alice has redeemed btc");
state5.claim_xmr(monero_wallet).await?; state5.claim_xmr(monero_wallet).await?;
@ -231,7 +228,7 @@ impl State0 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State1 { pub struct State1 {
A: bitcoin::PublicKey, A: bitcoin::PublicKey,
b: bitcoin::SecretKey, b: bitcoin::SecretKey,
@ -294,7 +291,7 @@ impl State1 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State2 { pub struct State2 {
A: bitcoin::PublicKey, A: bitcoin::PublicKey,
b: bitcoin::SecretKey, b: bitcoin::SecretKey,
@ -365,7 +362,7 @@ impl State2 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State3 { pub struct State3 {
A: bitcoin::PublicKey, A: bitcoin::PublicKey,
b: bitcoin::SecretKey, b: bitcoin::SecretKey,
@ -471,7 +468,7 @@ impl State3 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State4 { pub struct State4 {
A: bitcoin::PublicKey, A: bitcoin::PublicKey,
b: bitcoin::SecretKey, b: bitcoin::SecretKey,
@ -538,7 +535,7 @@ impl State4 {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug)]
pub struct State5 { pub struct State5 {
A: bitcoin::PublicKey, A: bitcoin::PublicKey,
b: bitcoin::SecretKey, b: bitcoin::SecretKey,