This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
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.
Simplify unexpiration logic in convertValidationResultsIntoOrderEvents #856
Simplify unexpiration logic in convertValidationResultsIntoOrderEvents #856
Changes from 8 commits
f7153a8
153461c
04fbfe0
178a798
8791f48
991a69d
788e8db
00ff1f6
26d82c5
8616a0f
4101686
54a5bb3
4931b64
dd1dd2d
a96329d
4e17262
7eeb2e2
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.
It looks like in the new version we do not check
oldFillableAmount.Cmp(newFillableAmount) == 0
before considering the order unexpired. Is there a reason this check is not required? Or to phrase it another way, do we know why this check was here in the old version of the code?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.
Currently, in addition to checking for unexpiration, we check for the three cases (
oldFillableAmount.Cmp(newFillableAmount) == 0
,oldFillableAmount.Cmp(newFillableAmount) != 0 && oldAmountIsMoreThenNewAmount
, andoldFillableAmount.Cmp(newFillableAmount) != 0 && !oldAmountIsMoreThenNewAmount
) and do the same thing in all three cases. Since we've covered all the possibilities, this comparison check is not needed at all.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 way this is written is somewhat confusing. At this point in the code, we have not checked if the fillable amount actually changed, and yet we are still calling a function to update it in the database. It's also slightly less efficient since it is potentially updating a field in the database that doesn't actually need to change (though I'm less concerned about that part).
Can you refactor this or maybe just rename
updateOrderFillableTakerAssetAmount
to make this more clear?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 renamed it to updateOrderFillableTakerAssetAmountAndBlockInfo. I'm going to make another PR that unifies
updateOrderFillableTakerAssetAmountAndBlockInfo
,rewatchOrder
, andunwatchOrder
, since they're all the same, except for how they handleIsRemoved
.