Remove unecessary fields from bob::SwapFactory

This commit is contained in:
Franck Royer 2021-01-19 14:36:24 +11:00
parent 3c68026cfe
commit e26629b593
No known key found for this signature in database
GPG key ID: A82ED75A8DFC50A4
3 changed files with 15 additions and 36 deletions

View file

@ -112,7 +112,7 @@ async fn main() -> Result<()> {
xmr: receive_monero,
};
let (bitcoin_wallet, monero_wallet, starting_balances) = setup_wallets(
let (bitcoin_wallet, monero_wallet, _starting_balances) = setup_wallets(
bitcoind_url,
bitcoin_wallet_name.as_str(),
monero_wallet_rpc_url,
@ -133,12 +133,10 @@ async fn main() -> Result<()> {
swap_id,
bitcoin_wallet,
monero_wallet,
config,
starting_balances,
alice_addr,
alice_peer_id,
);
let (swap, event_loop) = bob_factory.new_swap_as_bob(swap_amounts).await?;
let (swap, event_loop) = bob_factory.new_swap_as_bob(swap_amounts, config).await?;
tokio::spawn(async move { event_loop.run().await });
bob::run(swap).await?;
@ -196,7 +194,7 @@ async fn main() -> Result<()> {
alice_peer_id,
alice_addr,
}) => {
let (bitcoin_wallet, monero_wallet, starting_balances) = setup_wallets(
let (bitcoin_wallet, monero_wallet, _starting_balances) = setup_wallets(
bitcoind_url,
bitcoin_wallet_name.as_str(),
monero_wallet_rpc_url,
@ -210,8 +208,6 @@ async fn main() -> Result<()> {
swap_id,
bitcoin_wallet,
monero_wallet,
config,
starting_balances,
alice_addr,
alice_peer_id,
);

View file

@ -55,26 +55,21 @@ pub struct SwapFactory {
identity: Keypair,
peer_id: PeerId,
db_path: PathBuf,
config: Config,
alice_connect_address: Multiaddr,
alice_connect_peer_id: PeerId,
pub bitcoin_wallet: Arc<bitcoin::Wallet>,
pub monero_wallet: Arc<monero::Wallet>,
pub starting_balances: StartingBalances,
}
impl SwapFactory {
#[allow(clippy::too_many_arguments)]
pub fn new(
seed: Seed,
db_path: PathBuf,
swap_id: Uuid,
bitcoin_wallet: Arc<bitcoin::Wallet>,
monero_wallet: Arc<monero::Wallet>,
config: Config,
starting_balances: StartingBalances,
alice_connect_address: Multiaddr,
alice_connect_peer_id: PeerId,
) -> Self {
@ -86,24 +81,23 @@ impl SwapFactory {
identity,
peer_id,
db_path,
config,
alice_connect_address,
alice_connect_peer_id,
bitcoin_wallet,
monero_wallet,
starting_balances,
}
}
pub async fn new_swap_as_bob(
&self,
swap_amounts: SwapAmounts,
config: Config,
) -> Result<(bob::Swap, bob::EventLoop)> {
let initial_state = init_bob_state(
swap_amounts.btc,
swap_amounts.xmr,
self.bitcoin_wallet.clone(),
self.config,
config,
)
.await?;