mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-11-19 09:25:33 +00:00
Save state0 in the swarm to process message0
This commit is contained in:
parent
d8218a7bea
commit
2abeba17f9
@ -71,6 +71,24 @@ pub async fn negotiate(
|
|||||||
// TODO: get an ack from libp2p2
|
// TODO: get an ack from libp2p2
|
||||||
swarm.send_amounts(channel, amounts);
|
swarm.send_amounts(channel, amounts);
|
||||||
|
|
||||||
|
let redeem_address = bitcoin_wallet.as_ref().new_address().await?;
|
||||||
|
let punish_address = redeem_address.clone();
|
||||||
|
|
||||||
|
let state0 = State0::new(
|
||||||
|
a,
|
||||||
|
s_a,
|
||||||
|
v_a,
|
||||||
|
amounts.btc,
|
||||||
|
amounts.xmr,
|
||||||
|
REFUND_TIMELOCK,
|
||||||
|
PUNISH_TIMELOCK,
|
||||||
|
redeem_address,
|
||||||
|
punish_address,
|
||||||
|
);
|
||||||
|
|
||||||
|
// TODO(Franck): Understand why this is needed.
|
||||||
|
swarm.set_state0(state0.clone());
|
||||||
|
|
||||||
let event = timeout(*BOB_TIME_TO_ACT, swarm.next())
|
let event = timeout(*BOB_TIME_TO_ACT, swarm.next())
|
||||||
.await
|
.await
|
||||||
.context("Failed to receive message 0 from Bob")?;
|
.context("Failed to receive message 0 from Bob")?;
|
||||||
@ -81,21 +99,6 @@ pub async fn negotiate(
|
|||||||
|
|
||||||
let SwapAmounts { btc, xmr } = amounts;
|
let SwapAmounts { btc, xmr } = amounts;
|
||||||
|
|
||||||
let redeem_address = bitcoin_wallet.as_ref().new_address().await?;
|
|
||||||
let punish_address = redeem_address.clone();
|
|
||||||
|
|
||||||
let state0 = State0::new(
|
|
||||||
a,
|
|
||||||
s_a,
|
|
||||||
v_a,
|
|
||||||
btc,
|
|
||||||
xmr,
|
|
||||||
REFUND_TIMELOCK,
|
|
||||||
PUNISH_TIMELOCK,
|
|
||||||
redeem_address,
|
|
||||||
punish_address,
|
|
||||||
);
|
|
||||||
|
|
||||||
let state1 = state0.receive(message0)?;
|
let state1 = state0.receive(message0)?;
|
||||||
|
|
||||||
let event = timeout(*BOB_TIME_TO_ACT, swarm.next())
|
let event = timeout(*BOB_TIME_TO_ACT, swarm.next())
|
||||||
|
Loading…
Reference in New Issue
Block a user