246: Change anyhow! to bail! in error scenarios r=da-kami a=da-kami

Unfortunately I handled the two failure scenarios in the ASB wrong - I thought that was fixed already, but that was different logic in a different PR. 

😬😬😬

Co-authored-by: Daniel Karzel <daniel@comit.network>
pull/254/head
bors[bot] 3 years ago committed by GitHub
commit 108bc4c3ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,7 +16,7 @@ use crate::{
}, },
seed::Seed, seed::Seed,
}; };
use anyhow::{anyhow, Context, Result}; use anyhow::{bail, Context, Result};
use futures::future::RemoteHandle; use futures::future::RemoteHandle;
use libp2p::{ use libp2p::{
core::Multiaddr, futures::FutureExt, request_response::ResponseChannel, PeerId, Swarm, core::Multiaddr, futures::FutureExt, request_response::ResponseChannel, PeerId, Swarm,
@ -221,19 +221,19 @@ where
let xmr_amount = rate.sell_quote(btc_amount)?; let xmr_amount = rate.sell_quote(btc_amount)?;
if xmr_amount > self.max_sell { if xmr_amount > self.max_sell {
anyhow!(MaximumSellAmountExceeded { bail!(MaximumSellAmountExceeded {
actual: xmr_amount, actual: xmr_amount,
max_sell: self.max_sell max_sell: self.max_sell
}); })
} }
let xmr_balance = monero_wallet.get_balance().await?; let xmr_balance = monero_wallet.get_balance().await?;
let xmr_lock_fees = monero_wallet.static_tx_fee_estimate(); let xmr_lock_fees = monero_wallet.static_tx_fee_estimate();
if xmr_balance < xmr_amount + xmr_lock_fees { if xmr_balance < xmr_amount + xmr_lock_fees {
anyhow!(BalanceTooLow { bail!(BalanceTooLow {
balance: xmr_balance balance: xmr_balance
}); })
} }
let quote_response = QuoteResponse { xmr_amount }; let quote_response = QuoteResponse { xmr_amount };

Loading…
Cancel
Save