diff --git a/mm2src/mm2_main/src/lp_ordermatch.rs b/mm2src/mm2_main/src/lp_ordermatch.rs index b8890daf03..29bb138c02 100644 --- a/mm2src/mm2_main/src/lp_ordermatch.rs +++ b/mm2src/mm2_main/src/lp_ordermatch.rs @@ -376,7 +376,7 @@ fn process_maker_order_cancelled( } } else { // Add the order to the recently cancelled list to ignore it - // if a new order with the same uuid is received within the RECENTLY_CANCELLED_TIMEOUT timeframe + // if a new order with the same uuid is received within the `RECENTLY_CANCELLED_TIMEOUT` timeframe // We only do this if the order is not in the order_set, because if it is, it means that the order was already // created and messages did arrive in the correct order orderbook.recently_cancelled.insert(uuid, from_pubkey); @@ -2512,7 +2512,8 @@ struct Orderbook { /// a map of orderbook states of known maker pubkeys pubkeys_state: HashMap, /// The `TimeCache` of recently canceled orders, mapping `Uuid` to the maker pubkey as `String`, - /// used to avoid order recreation in case of out of order p2p messages. + /// used to avoid order recreation in case of out-of-order p2p messages, + /// e.g., when receiving the order cancellation message before the order is created. /// Entries are kept for `RECENTLY_CANCELLED_TIMEOUT` seconds. recently_cancelled: TimeCache, topics_subscribed_to: HashMap, diff --git a/mm2src/mm2_main/tests/mm2_tests/mm2_tests_inner.rs b/mm2src/mm2_main/tests/mm2_tests/mm2_tests_inner.rs index 45386c1e50..1d05ef6922 100644 --- a/mm2src/mm2_main/tests/mm2_tests/mm2_tests_inner.rs +++ b/mm2src/mm2_main/tests/mm2_tests/mm2_tests_inner.rs @@ -1564,7 +1564,7 @@ fn test_cancel_order() { assert_eq!(alice_orderbook.asks.len(), 0, "Alice RICK/MORTY asks are not empty"); } -/// This also covers recently canceled orders implementation. +/// This also covers the case where order creation/cancellation messages are received out of sequence. /// The cancellation message sometimes arrives to Alice before the order creation message, /// in this case Alice gets the order creation message from p2p cache using IHAVE / IWANT control messages. #[test]