swap_setup instead of spot_price and execution_setup

Having `spot_price` and `execution_setup` as separate protocols did not bring any advantages, but was problematic because we had to ensure that `execution_setup` would be triggered after `spot_price`. Because of this dependency it is better to combine the protocols into one.

Combining the protocols also allows a refactoring to get rid of the `libp2p-async-await` dependency.

Alice always listens for the `swap_setup` protocol. When Bob opens a substream on that protocol the spot price is communicated, and then all execution setup messages (swap-id and signature exchange).
This commit is contained in:
Daniel Karzel 2021-06-24 13:54:26 +10:00
parent ada5acb2b5
commit 818147a629
No known key found for this signature in database
GPG key ID: 30C3FC2E438ADB6E
30 changed files with 1063 additions and 1563 deletions

View file

@ -46,7 +46,7 @@ impl From<BobState> for Bob {
fn from(bob_state: BobState) -> Self {
match bob_state {
BobState::Started { btc_amount } => Bob::Started { btc_amount },
BobState::ExecutionSetupDone(state2) => Bob::ExecutionSetupDone { state2 },
BobState::SwapSetupCompleted(state2) => Bob::ExecutionSetupDone { state2 },
BobState::BtcLocked(state3) => Bob::BtcLocked { state3 },
BobState::XmrLockProofReceived {
state,
@ -78,7 +78,7 @@ impl From<Bob> for BobState {
fn from(db_state: Bob) -> Self {
match db_state {
Bob::Started { btc_amount } => BobState::Started { btc_amount },
Bob::ExecutionSetupDone { state2 } => BobState::ExecutionSetupDone(state2),
Bob::ExecutionSetupDone { state2 } => BobState::SwapSetupCompleted(state2),
Bob::BtcLocked { state3 } => BobState::BtcLocked(state3),
Bob::XmrLockProofReceived {
state,