Skip to content

Commit

Permalink
add some doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shamardy committed Dec 10, 2024
1 parent f6471b5 commit 5eca01d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mm2src/mm2_main/src/lp_swap/maker_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,14 @@ impl MakerSwap {
Ok((Some(MakerSwapCommand::SendPayment), swap_events))
}

/// Sets up the watcher reward for the maker's payment in the swap.
///
/// The reward mainly serves as compensation to watchers for the mining fees
/// paid to execute the transactions.
///
/// The reward configuration depends on the specific requirements of the coins
/// involved in the swap.
/// Some coins may not support watcher rewards at all.
async fn setup_maker_watcher_reward(&self, wait_maker_payment_until: u64) -> Result<Option<WatcherReward>, String> {
if !self.r().watcher_reward {
return Ok(None);
Expand Down
15 changes: 15 additions & 0 deletions mm2src/mm2_main/src/lp_swap/taker_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,14 @@ impl TakerSwap {
}
}

/// Sets up the watcher reward for the taker's payment in the swap.
///
/// The reward mainly serves as compensation to watchers for the mining fees
/// paid to execute the transactions.
///
/// The reward configuration depends on the specific requirements of the coins
/// involved in the swap.
/// Some coins may not support watcher rewards at all.
async fn setup_watcher_reward(&self, taker_payment_lock: u64) -> Result<Option<WatcherReward>, String> {
if !self.r().watcher_reward {
return Ok(None);
Expand All @@ -1525,6 +1533,13 @@ impl TakerSwap {
.map_err(|err| ERRL!("Watcher reward error: {}", err.to_string()))
}

/// Processes watcher-related logic for the swap by preparing and broadcasting necessary data.
///
/// This function creates spend/refund preimages and broadcasts them to watchers if both coins
/// support watcher functionality and watchers are enabled.
///
/// The preimages allow watchers to either complete the swap by spending the maker payment
/// or refund the taker payment if needed.
async fn process_watcher_logic(&self, transaction: &TransactionEnum) -> Option<TakerSwapEvent> {
let watchers_enabled_and_supported = self.ctx.use_watchers()
&& self.taker_coin.is_supported_by_watchers()
Expand Down

0 comments on commit 5eca01d

Please sign in to comment.