Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Added
QuoteMetadata
to/orders/uid
request #3222base: main
Are you sure you want to change the base?
Added
QuoteMetadata
to/orders/uid
request #3222Changes from 20 commits
1ccbf34
e6206ca
c7efc2d
a843053
10171e0
8808793
a7d3844
6b3840e
2f7915e
c028e13
4094f95
09f8f65
7424988
603401a
2c511f4
0e93b31
89928c0
dc548ad
61de451
6930802
baeeed7
77bdeec
81c3029
12e8c87
126a670
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
We could have an early return to
None
in order to avoid one indexation level.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'm not sure where we can do the early return, because for the
None
match we are checking jit orders.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.
Or
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.
Thank you @squadgazzz ! exactly I meant that.
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.
Ok, I get what you meant. Refactored.
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 much changed tbh :)
The main benefit of an early return is reducing indentation, making the code easier to read.
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.
So improved the code readability by moving the Quote match to separate function, but in my opinion I don't see here an issue with the indentation.
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.
the
db.insert_order()
signature is now quite weird to me. The order struct now contains quote metadata but we still pass an optional quote into it. This immediately begs the question what is supposed to happen whenorder.metadata.quote
is different from the passed in quote?Can this API be updated to not have this conflict anymore?
I suspect the underlying problem is probably that we are using the
Order
andOrderMetadata
struct in too many places so it currently wears a lot of different hats which don't quite work in all places. 🤔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.
The main issue is that
shared::order_quoting::Quote
returned byvalidate_and_construct_order()
can be converted tomodel::order::OrderQuote
(order.metadata.quote
field) but cannot be converted back (for storing in db) because of lack of some fields and I'm not sure if it is sensible to add all of the missing fields (mainly quoteid
which will be irrelevant after clearing quotes table, but also most of theQuoteData
fields).Also
order.metadata.quote
is created from thequote
so it always has the same 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.
That doesn't really help to reduce currently created confusion where we operate with 2 quotes related to the same order but in different representations.
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.
Still thinking about how this part can be improved:
services/crates/orderbook/src/database/orders.rs
Lines 240 to 242 in 81c3029
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'd say the main issue is that we pass a ton of data into the DB call that is actually not needed. I believe if we only pass the necessary data (signed order data + a few additional data) we'd not have the issue of passing 2 possibly conflicting
Quote
structs into the same call.