mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Add todos
This commit is contained in:
parent
6be5d64c1c
commit
194a19cf1d
@ -28,6 +28,9 @@ use xmr_btc::{alice::State0, bob, monero};
|
|||||||
|
|
||||||
pub type Swarm = libp2p::Swarm<Alice>;
|
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.
|
// FIXME: This whole function is horrible, needs total re-write.
|
||||||
pub async fn swap(
|
pub async fn swap(
|
||||||
listen: Multiaddr,
|
listen: Multiaddr,
|
||||||
@ -83,6 +86,7 @@ pub async fn swap(
|
|||||||
);
|
);
|
||||||
swarm.set_state0(state0.clone());
|
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 state1 = state0.receive(message0).expect("failed to receive msg 0");
|
||||||
|
|
||||||
let (state2, channel) = match swarm.next().await {
|
let (state2, channel) = match swarm.next().await {
|
||||||
|
@ -83,8 +83,9 @@ where
|
|||||||
swarm.send_message0(alice.clone(), state0.next_message(rng));
|
swarm.send_message0(alice.clone(), state0.next_message(rng));
|
||||||
let state1 = match swarm.next().await {
|
let state1 = match swarm.next().await {
|
||||||
OutEvent::Message0(msg) => {
|
OutEvent::Message0(msg) => {
|
||||||
state0.receive(&wallet, msg).await? // TODO: More graceful error
|
// TODO: Verify the response message before calling receive() and handle any
|
||||||
// handling.
|
// error gracefully.
|
||||||
|
state0.receive(&wallet, msg).await?
|
||||||
}
|
}
|
||||||
other => panic!("unexpected event: {:?}", other),
|
other => panic!("unexpected event: {:?}", other),
|
||||||
};
|
};
|
||||||
@ -92,7 +93,7 @@ where
|
|||||||
swarm.send_message1(alice.clone(), state1.next_message());
|
swarm.send_message1(alice.clone(), state1.next_message());
|
||||||
let state2 = match swarm.next().await {
|
let state2 = match swarm.next().await {
|
||||||
OutEvent::Message1(msg) => {
|
OutEvent::Message1(msg) => {
|
||||||
state1.receive(msg)? // TODO: More graceful error handling.
|
state1.receive(msg)? // TODO: Same as above.
|
||||||
}
|
}
|
||||||
other => panic!("unexpected event: {:?}", other),
|
other => panic!("unexpected event: {:?}", other),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user