Add todos

This commit is contained in:
Tobin C. Harding 2020-10-27 10:09:53 +11:00
parent 6be5d64c1c
commit 194a19cf1d
2 changed files with 8 additions and 3 deletions

View File

@ -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 {

View File

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