-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frank/dlob #12
frank/dlob #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Assuming we will rebuild the node list frequently the Box allocations (and deallocations) will become expensive
Suggest using something like https://crates.io/crates/typed-arena or an object pool to reuse allocations
- not sure the trait and distinct structs for each node type is helpful?
struct DlobNode {
order: Order,
user_account: Account,
kind: NodeKind,
next: Option<*mut DlobNode>,
prev: Option<*mut DlobNode>
}
- can't comment on the use of the raw pointers as I haven't used them much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of work done here! haven't grokked everything yet but left some simple feedback
} else if is_one_of_variant( | ||
&order.order_type, | ||
&[ | ||
OrderType::Market, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bit flags could help here (probably another PR): https://docs.rs/bitflags/latest/bitflags/#working-with-flags-values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure will do down the line, just need this merged in for jit maker rn
if self.order_sigs.contains_key(&order_sig) { | ||
self.order_sigs.remove(&order_sig); | ||
return Some(node); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.order_sigs.contains_key(&order_sig) { | |
self.order_sigs.remove(&order_sig); | |
return Some(node); | |
} | |
return self.order_sigs.remove(&order_sig) | |
} |
same for asks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't really like this because dashmap remove returns Option<K, V> so i'm getting Option<String, Node> out of here when all i actually want is Option Node and I can't transform Option<String, Node> with something annoying
} | ||
} | ||
|
||
pub(crate) type Exchange = DashMap<String, DashMap<u16, Market>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if hashmap makes sense vs. e.g a struct
struct Exchange {
perp: DashMap<u16, Market>>,
spot: DashMap<u16, Market>>,
}
} | ||
|
||
pub(crate) fn get_order_signature(order_id: u32, user_account: Pubkey) -> String { | ||
format!("{}-{}", order_id, user_account.to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about the string key, something like this with Display
/to_string method may be better
#[derive(Eq, Hash, PartialEq)]
struct OrderKey {
user: Pubkey,
order_id: u32,
}
pub type OrderKey = (Pubkey, u32);
could also work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the string key, i think for simplicity it makes a lot of sense
No description provided.