pull/28/head
Tobin C. Harding 4 years ago
parent 6be5d64c1c
commit 194a19cf1d

@ -28,6 +28,9 @@ use xmr_btc::{alice::State0, bob, monero};
pub type Swarm = libp2p::Swarm<Alice>;
// 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 {

@ -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),
};

Loading…
Cancel
Save