mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-15 08:38:58 -05:00
fix(asb): send zero quote on failure (#379)
* fix(asb): send zero quote on failure * static function for BidQuote::ZERO
This commit is contained in:
parent
119db50c11
commit
2ba69ba340
3 changed files with 21 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
- ASB: The maker will take Monero funds needed for ongoing swaps into consideration when making a quote. A warning will be displayed if the Monero funds do not cover all ongoing swaps.
|
- ASB: The maker will take Monero funds needed for ongoing swaps into consideration when making a quote. A warning will be displayed if the Monero funds do not cover all ongoing swaps.
|
||||||
|
- ASB: Return a zero quote when quoting fails instead of letting the request time out
|
||||||
|
|
||||||
## [1.1.7] - 2025-06-04
|
## [1.1.7] - 2025-06-04
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,8 +259,17 @@ where
|
||||||
// The error is already logged in the make_quote_or_use_cached function
|
// The error is already logged in the make_quote_or_use_cached function
|
||||||
// We don't log it here to avoid spamming on each request
|
// We don't log it here to avoid spamming on each request
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// TODO: Respond with the error to Bob. Currently this will timeout on Bob's side.
|
// We respond with a zero quote. This will stop Bob from trying to start a swap but doesn't require
|
||||||
continue;
|
// a breaking network change by changing the definition of the quote protocol
|
||||||
|
if self
|
||||||
|
.swarm
|
||||||
|
.behaviour_mut()
|
||||||
|
.quote
|
||||||
|
.send_response(channel, BidQuote::ZERO)
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
tracing::debug!(%peer, "Failed to respond with zero quote");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,15 @@ pub struct BidQuote {
|
||||||
pub max_quantity: bitcoin::Amount,
|
pub max_quantity: bitcoin::Amount,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BidQuote {
|
||||||
|
/// A zero quote with all amounts set to zero
|
||||||
|
pub const ZERO: Self = Self {
|
||||||
|
price: bitcoin::Amount::ZERO,
|
||||||
|
min_quantity: bitcoin::Amount::ZERO,
|
||||||
|
max_quantity: bitcoin::Amount::ZERO,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, thiserror::Error)]
|
#[derive(Clone, Copy, Debug, thiserror::Error)]
|
||||||
#[error("Received quote of 0")]
|
#[error("Received quote of 0")]
|
||||||
pub struct ZeroQuoteReceived;
|
pub struct ZeroQuoteReceived;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue