From 194a19cf1dd17cabda249e1a3bbaea3a332ca470 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 27 Oct 2020 10:09:53 +1100 Subject: [PATCH] Add todos --- swap/src/alice.rs | 4 ++++ swap/src/bob.rs | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/swap/src/alice.rs b/swap/src/alice.rs index 210a2451..b0553bd3 100644 --- a/swap/src/alice.rs +++ b/swap/src/alice.rs @@ -28,6 +28,9 @@ use xmr_btc::{alice::State0, bob, monero}; pub type Swarm = libp2p::Swarm; +// TODO: After we have done some testing replace all the 'panic's with log +// statements or error returns. + // FIXME: This whole function is horrible, needs total re-write. pub async fn swap( listen: Multiaddr, @@ -83,6 +86,7 @@ pub async fn swap( ); swarm.set_state0(state0.clone()); + // TODO: Can we verify message 0 before calling this so we never fail? let state1 = state0.receive(message0).expect("failed to receive msg 0"); let (state2, channel) = match swarm.next().await { diff --git a/swap/src/bob.rs b/swap/src/bob.rs index 1d7d08ad..c563146e 100644 --- a/swap/src/bob.rs +++ b/swap/src/bob.rs @@ -83,8 +83,9 @@ where swarm.send_message0(alice.clone(), state0.next_message(rng)); let state1 = match swarm.next().await { OutEvent::Message0(msg) => { - state0.receive(&wallet, msg).await? // TODO: More graceful error - // handling. + // TODO: Verify the response message before calling receive() and handle any + // error gracefully. + state0.receive(&wallet, msg).await? } other => panic!("unexpected event: {:?}", other), }; @@ -92,7 +93,7 @@ where swarm.send_message1(alice.clone(), state1.next_message()); let state2 = match swarm.next().await { OutEvent::Message1(msg) => { - state1.receive(msg)? // TODO: More graceful error handling. + state1.receive(msg)? // TODO: Same as above. } other => panic!("unexpected event: {:?}", other), };