Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mm2src/mm2_main/src/lp_ordermatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4262,6 +4262,12 @@ async fn handle_timed_out_maker_matches(ctx: MmArc, ordermatch_ctx: &OrdermatchC
}
}

/// Taker processes MakerReserved messages.
/// The messages are sorted by maker prices (ascending) and the first message that matches the taker order is selected.
///
/// This function is spawned for each MakerReserved message incoming from different makers
/// but only one instance will stay running after the received message is added into the pending map.
/// The running instance waits for a few secs and processes all pending MakerReserved messages.
async fn process_maker_reserved(ctx: MmArc, from_pubkey: H256Json, reserved_msg: MakerReserved) {
log::debug!("Processing MakerReserved {:?}", reserved_msg);
let ordermatch_ctx = OrdermatchContext::from_ctx(&ctx).unwrap();
Expand Down Expand Up @@ -4289,7 +4295,8 @@ async fn process_maker_reserved(ctx: MmArc, from_pubkey: H256Json, reserved_msg:
.or_insert_with(Vec::new);
pending_for_order.push(reserved_msg);
if pending_for_order.len() > 1 {
// messages will be sorted by price and processed in the first called handler
// Cancel second+ process_maker_reserved handlers.
// Messages will be sorted by price and processed in the first spawned handler
return;
}
}
Expand Down
6 changes: 5 additions & 1 deletion mm2src/mm2_main/src/lp_swap/taker_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,9 @@ impl TakerSwapEvent {
fn should_ban_maker(&self) -> bool {
matches!(
self,
TakerSwapEvent::MakerPaymentValidateFailed(_) | TakerSwapEvent::TakerPaymentWaitForSpendFailed(_)
TakerSwapEvent::NegotiateFailed(_)
| TakerSwapEvent::MakerPaymentValidateFailed(_)
| TakerSwapEvent::TakerPaymentWaitForSpendFailed(_)
)
}

Expand Down Expand Up @@ -3293,6 +3295,8 @@ mod taker_swap_tests {

let event = TakerSwapEvent::TakerPaymentWaitForSpendFailed("err".into());
assert!(event.should_ban_maker());
let event = TakerSwapEvent::NegotiateFailed("err".into());
assert!(event.should_ban_maker());
}

#[test]
Expand Down
Loading