Make ReceiveTransferProof async and take &mut self

This commit is contained in:
Lucas Soriano del Pino 2020-10-16 10:49:34 +11:00
parent 3492c46e71
commit 176b2195e3
2 changed files with 8 additions and 5 deletions

View File

@ -76,8 +76,9 @@ pub enum Action {
}
// TODO: This could be moved to the monero module
#[async_trait]
pub trait ReceiveTransferProof {
fn receive_transfer_proof(&self) -> monero::TransferProof;
async fn receive_transfer_proof(&mut self) -> monero::TransferProof;
}
#[async_trait]
@ -90,7 +91,7 @@ pub trait MedianTime {
/// This is called post handshake, after all the keys, addresses and most of the
/// signatures have been exchanged.
pub fn action_generator_bob<N, M, B>(
network: &'static N,
network: &'static mut N,
monero_ledger: &'static M,
bitcoin_ledger: &'static B,
// TODO: Replace this with a new, slimmer struct?
@ -150,7 +151,7 @@ where
futures::pin_mut!(poll_until_btc_has_expired);
// the source of this could be the database, this layer doesn't care
let transfer_proof = network.receive_transfer_proof();
let transfer_proof = network.receive_transfer_proof().await;
let S_b_monero = monero::PublicKey::from_private_key(&monero::PrivateKey::from_scalar(
s_b.into_ed25519(),

View File

@ -1,6 +1,7 @@
pub mod harness;
use anyhow::Result;
use async_trait::async_trait;
use genawaiter::GeneratorState;
use harness::wallet::{bitcoin, monero};
use xmr_btc::{
@ -13,14 +14,15 @@ use xmr_btc::{
struct Network;
#[async_trait]
impl ReceiveTransferProof for Network {
fn receive_transfer_proof(&self) -> xmr_btc::monero::TransferProof {
async fn receive_transfer_proof(&mut self) -> xmr_btc::monero::TransferProof {
todo!("use libp2p")
}
}
async fn swap_as_bob(
network: &'static Network,
network: &'static mut Network,
monero_wallet: &'static monero::BobWallet<'static>,
bitcoin_wallet: &'static bitcoin::Wallet,
state: bob::State2,