mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-06-07 06:33:04 -04:00
Merge pull request #25 from comit-network/unused-assigments
Remove allow(unused_assignments) attribute
This commit is contained in:
commit
5da84a3d48
1 changed files with 3 additions and 7 deletions
|
@ -29,13 +29,12 @@ use xmr_btc::{alice::State0, bob, monero};
|
||||||
pub type Swarm = libp2p::Swarm<Alice>;
|
pub type Swarm = libp2p::Swarm<Alice>;
|
||||||
|
|
||||||
// FIXME: This whole function is horrible, needs total re-write.
|
// FIXME: This whole function is horrible, needs total re-write.
|
||||||
#[allow(unused_assignments)] // Due to the mutable message0?
|
|
||||||
pub async fn swap(
|
pub async fn swap(
|
||||||
listen: Multiaddr,
|
listen: Multiaddr,
|
||||||
redeem_address: ::bitcoin::Address,
|
redeem_address: ::bitcoin::Address,
|
||||||
punish_address: ::bitcoin::Address,
|
punish_address: ::bitcoin::Address,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut message0: Option<bob::Message0> = None;
|
let message0: bob::Message0;
|
||||||
let mut last_amounts: Option<SwapAmounts> = None;
|
let mut last_amounts: Option<SwapAmounts> = None;
|
||||||
|
|
||||||
let mut swarm = new_swarm(listen)?;
|
let mut swarm = new_swarm(listen)?;
|
||||||
|
@ -54,7 +53,7 @@ pub async fn swap(
|
||||||
OutEvent::Message0(msg) => {
|
OutEvent::Message0(msg) => {
|
||||||
debug!("Got message0 from Bob");
|
debug!("Got message0 from Bob");
|
||||||
// TODO: Do this in a more Rusty/functional way.
|
// TODO: Do this in a more Rusty/functional way.
|
||||||
message0 = Some(msg);
|
message0 = msg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
other => panic!("Unexpected event: {:?}", other),
|
other => panic!("Unexpected event: {:?}", other),
|
||||||
|
@ -83,10 +82,7 @@ pub async fn swap(
|
||||||
);
|
);
|
||||||
swarm.set_state0(state0.clone());
|
swarm.set_state0(state0.clone());
|
||||||
|
|
||||||
let state1 = match message0 {
|
let state1 = state0.receive(message0).expect("failed to receive msg 0");
|
||||||
Some(msg) => state0.receive(msg).expect("failed to receive msg 0"),
|
|
||||||
None => panic!("should have the message by here"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let (state2, channel) = match swarm.next().await {
|
let (state2, channel) = match swarm.next().await {
|
||||||
OutEvent::Message1 { msg, channel } => {
|
OutEvent::Message1 { msg, channel } => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue