mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-13 00:19:31 -05:00
Rename bob::Message1 to Message2
As per sequence diagram.
This commit is contained in:
parent
0d1be52966
commit
18f326ddd1
@ -2,7 +2,7 @@ use crate::protocol::{
|
|||||||
alice,
|
alice,
|
||||||
alice::{Message3, TransferProof},
|
alice::{Message3, TransferProof},
|
||||||
bob,
|
bob,
|
||||||
bob::{EncryptedSignature, Message4},
|
bob::{EncryptedSignature, Message2, Message4},
|
||||||
};
|
};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
@ -27,7 +27,7 @@ pub const BUF_SIZE: usize = 1024 * 1024;
|
|||||||
pub enum BobToAlice {
|
pub enum BobToAlice {
|
||||||
SwapRequest(Box<bob::SwapRequest>),
|
SwapRequest(Box<bob::SwapRequest>),
|
||||||
Message0(Box<bob::Message0>),
|
Message0(Box<bob::Message0>),
|
||||||
Message1(Box<bob::Message1>),
|
Message2(Box<Message2>),
|
||||||
Message4(Box<Message4>),
|
Message4(Box<Message4>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use crate::{
|
|||||||
protocol::{
|
protocol::{
|
||||||
alice::{State0, State3},
|
alice::{State0, State3},
|
||||||
bob,
|
bob,
|
||||||
bob::Message4,
|
bob::{Message2, Message4},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use anyhow::{Context, Error, Result};
|
use anyhow::{Context, Error, Result};
|
||||||
@ -82,11 +82,11 @@ impl Behaviour {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let state2 = {
|
let state2 = {
|
||||||
let bob_message1 = serde_cbor::from_slice::<bob::Message1>(
|
let message2 = serde_cbor::from_slice::<Message2>(
|
||||||
&substream.read_message(BUF_SIZE).await?,
|
&substream.read_message(BUF_SIZE).await?,
|
||||||
)
|
)
|
||||||
.context("failed to deserialize message1")?;
|
.context("failed to deserialize message2")?;
|
||||||
state1.receive(bob_message1)
|
state1.receive(message2)
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ use crate::{
|
|||||||
alice,
|
alice,
|
||||||
alice::{Message3, TransferProof},
|
alice::{Message3, TransferProof},
|
||||||
bob,
|
bob,
|
||||||
bob::{EncryptedSignature, Message4},
|
bob::{EncryptedSignature, Message2, Message4},
|
||||||
SwapAmounts,
|
SwapAmounts,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -197,7 +197,7 @@ pub struct State1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl State1 {
|
impl State1 {
|
||||||
pub fn receive(self, msg: bob::Message1) -> State2 {
|
pub fn receive(self, msg: Message2) -> State2 {
|
||||||
State2 {
|
State2 {
|
||||||
a: self.a,
|
a: self.a,
|
||||||
B: self.B,
|
B: self.B,
|
||||||
|
@ -26,7 +26,7 @@ pub use self::{
|
|||||||
swap::{run, run_until},
|
swap::{run, run_until},
|
||||||
swap_request::*,
|
swap_request::*,
|
||||||
};
|
};
|
||||||
pub use execution_setup::{Message0, Message1, Message4};
|
pub use execution_setup::{Message0, Message2, Message4};
|
||||||
|
|
||||||
mod encrypted_signature;
|
mod encrypted_signature;
|
||||||
pub mod event_loop;
|
pub mod event_loop;
|
||||||
|
@ -24,7 +24,7 @@ pub struct Message0 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct Message1 {
|
pub struct Message2 {
|
||||||
pub(crate) tx_lock: crate::bitcoin::TxLock,
|
pub(crate) tx_lock: crate::bitcoin::TxLock,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,11 +90,11 @@ impl Behaviour {
|
|||||||
.receive(bitcoin_wallet.as_ref(), alice_message0)
|
.receive(bitcoin_wallet.as_ref(), alice_message0)
|
||||||
.await?;
|
.await?;
|
||||||
{
|
{
|
||||||
let bob_message1 = state1.next_message();
|
let message2 = state1.next_message();
|
||||||
substream
|
substream
|
||||||
.write_message(
|
.write_message(
|
||||||
&serde_cbor::to_vec(&bob_message1)
|
&serde_cbor::to_vec(&message2)
|
||||||
.context("failed to serialize Message1")?,
|
.context("failed to serialize message2")?,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ use crate::{
|
|||||||
alice,
|
alice,
|
||||||
alice::Message3,
|
alice::Message3,
|
||||||
bob,
|
bob,
|
||||||
bob::{EncryptedSignature, Message4},
|
bob::{EncryptedSignature, Message2, Message4},
|
||||||
SwapAmounts,
|
SwapAmounts,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -189,8 +189,8 @@ pub struct State1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl State1 {
|
impl State1 {
|
||||||
pub fn next_message(&self) -> bob::Message1 {
|
pub fn next_message(&self) -> Message2 {
|
||||||
bob::Message1 {
|
Message2 {
|
||||||
tx_lock: self.tx_lock.clone(),
|
tx_lock: self.tx_lock.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user