Skip to content

Commit

Permalink
resolve incompatibilities
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Jan 22, 2025
1 parent a849ff5 commit 6855e06
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions mm2src/mm2_main/src/lp_ordermatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,7 @@ impl<Key, Value> TrieDiffHistory<Key, Value> {
fn get(&self, key: &H64) -> Option<&TrieDiff<Key, Value>> { self.inner.get(key) }

#[allow(dead_code)]
fn len(&self) -> usize { self.inner.len() }
fn len(&self) -> usize { self.inner.len_unchecked() }
}

type TrieOrderHistory = TrieDiffHistory<Uuid, OrderbookItem>;
Expand Down Expand Up @@ -2549,7 +2549,14 @@ impl Orderbook {
}

if prev_root != H64::default() {
let history = match pubkey_state.order_pairs_trie_state_history.get_mut(&alb_ordered) {
let _ = pubkey_state
.order_pairs_trie_state_history
.update_expiration_status(alb_ordered.clone(), Duration::from_secs(TRIE_STATE_HISTORY_TIMEOUT));

let history = match pubkey_state
.order_pairs_trie_state_history
.get_mut_unchecked(&alb_ordered)
{
Some(t) => t,
None => {
pubkey_state.order_pairs_trie_state_history.insert_expirable(
Expand All @@ -2566,6 +2573,7 @@ impl Orderbook {
.expect("must exist")
},
};

history.insert_new_diff(prev_root, TrieDiff {
delta: vec![(order.uuid, Some(order.clone()))],
next_root: *pair_root,
Expand Down Expand Up @@ -2664,29 +2672,20 @@ impl Orderbook {
},
};

if pubkey_state.order_pairs_trie_state_history.get(&alb_ordered).is_some() {
let history = match pubkey_state.order_pairs_trie_state_history.get_mut(&alb_ordered) {
Some(t) => t,
None => {
pubkey_state.order_pairs_trie_state_history.insert_expirable(
alb_ordered.clone(),
TrieOrderHistory {
inner: TimedMap::new_with_map_kind(MapKind::FxHashMap),
},
Duration::from_secs(TRIE_STATE_HISTORY_TIMEOUT),
);
pubkey_state
.order_pairs_trie_state_history
.get_mut_unchecked(&alb_ordered)
.expect("must exist")
},
};
let _ = pubkey_state
.order_pairs_trie_state_history
.update_expiration_status(alb_ordered.clone(), Duration::from_secs(TRIE_STATE_HISTORY_TIMEOUT));

if let Some(history) = pubkey_state
.order_pairs_trie_state_history
.get_mut_unchecked(&alb_ordered)
{
history.insert_new_diff(old_state, TrieDiff {
delta: vec![(uuid, None)],
next_root: *pair_state,
});
}
};

Some(order)
}

Expand Down

0 comments on commit 6855e06

Please sign in to comment.