Rename bob::Message1 to Message2

As per sequence diagram.
This commit is contained in:
Franck Royer 2021-02-04 11:49:13 +11:00
parent 0d1be52966
commit 18f326ddd1
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
6 changed files with 16 additions and 16 deletions

View File

@ -2,7 +2,7 @@ use crate::protocol::{
alice,
alice::{Message3, TransferProof},
bob,
bob::{EncryptedSignature, Message4},
bob::{EncryptedSignature, Message2, Message4},
};
use async_trait::async_trait;
use futures::prelude::*;
@ -27,7 +27,7 @@ pub const BUF_SIZE: usize = 1024 * 1024;
pub enum BobToAlice {
SwapRequest(Box<bob::SwapRequest>),
Message0(Box<bob::Message0>),
Message1(Box<bob::Message1>),
Message2(Box<Message2>),
Message4(Box<Message4>),
}

View File

@ -6,7 +6,7 @@ use crate::{
protocol::{
alice::{State0, State3},
bob,
bob::Message4,
bob::{Message2, Message4},
},
};
use anyhow::{Context, Error, Result};
@ -82,11 +82,11 @@ impl Behaviour {
.await?;
let state2 = {
let bob_message1 = serde_cbor::from_slice::<bob::Message1>(
let message2 = serde_cbor::from_slice::<Message2>(
&substream.read_message(BUF_SIZE).await?,
)
.context("failed to deserialize message1")?;
state1.receive(bob_message1)
.context("failed to deserialize message2")?;
state1.receive(message2)
};
{

View File

@ -11,7 +11,7 @@ use crate::{
alice,
alice::{Message3, TransferProof},
bob,
bob::{EncryptedSignature, Message4},
bob::{EncryptedSignature, Message2, Message4},
SwapAmounts,
},
};
@ -197,7 +197,7 @@ pub struct State1 {
}
impl State1 {
pub fn receive(self, msg: bob::Message1) -> State2 {
pub fn receive(self, msg: Message2) -> State2 {
State2 {
a: self.a,
B: self.B,

View File

@ -26,7 +26,7 @@ pub use self::{
swap::{run, run_until},
swap_request::*,
};
pub use execution_setup::{Message0, Message1, Message4};
pub use execution_setup::{Message0, Message2, Message4};
mod encrypted_signature;
pub mod event_loop;

View File

@ -24,7 +24,7 @@ pub struct Message0 {
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Message1 {
pub struct Message2 {
pub(crate) tx_lock: crate::bitcoin::TxLock,
}
@ -90,11 +90,11 @@ impl Behaviour {
.receive(bitcoin_wallet.as_ref(), alice_message0)
.await?;
{
let bob_message1 = state1.next_message();
let message2 = state1.next_message();
substream
.write_message(
&serde_cbor::to_vec(&bob_message1)
.context("failed to serialize Message1")?,
&serde_cbor::to_vec(&message2)
.context("failed to serialize message2")?,
)
.await?;
}

View File

@ -13,7 +13,7 @@ use crate::{
alice,
alice::Message3,
bob,
bob::{EncryptedSignature, Message4},
bob::{EncryptedSignature, Message2, Message4},
SwapAmounts,
},
};
@ -189,8 +189,8 @@ pub struct State1 {
}
impl State1 {
pub fn next_message(&self) -> bob::Message1 {
bob::Message1 {
pub fn next_message(&self) -> Message2 {
Message2 {
tx_lock: self.tx_lock.clone(),
}
}