-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Call order and bitAsset related code refactory #1306
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.
Looks good, thanks.
libraries/chain/db_market.cpp
Outdated
modify( borrower_statistics, [&]( account_statistics_object& b ){ | ||
if( collateral_freed.valid() && collateral_freed->amount > 0 && collateral_freed->asset_id == asset_id_type() ) | ||
b.total_core_in_orders -= collateral_freed->amount; | ||
modify( get_account_stats_by_owner(order.borrower), [&collateral_freed,&pays]( account_statistics_object& b ){ |
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.
Only call modify if pays.asset_id == asset_id_type()
(this also implies collateral_freed.asset_id == core if collateral_freed is defined)
libraries/chain/db_market.cpp
Outdated
}); | ||
|
||
const account_object& borrower = order.borrower(*this); | ||
// adjust balance and/or account statistics | ||
if( collateral_freed.valid() || pays.asset_id == asset_id_type() ) |
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.
Add condition && collateral_freed.amount != 0
?
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.
Actually the code is a bit messy here for potential better performance.
- The
OR
check here is for only updating the object once when possible; - in most cases
collateral_freed.amount
is non-zero so it doesn't make much sense to add a check;- in addition,
adjust_balance()
will check if the delta is zero;
- in addition,
- actually there is a chance that we don't need to execute the
modify
, since actuallypays.asset_id
andcollateral_freed->asset_id
are the same, that means if we don't need to updatetotal_core_in_orders
due topays
, we won't need to update it due tocollateral_freed
. I will improve this. (Just saw your comment above)
and added comment in call_order_update_evaluator::do_evaluate()
@pmconrad please review again. Thanks a lot. |
While working on #1270, I ended up refactoring quite some code. Since the change is getting large, for easier code review in the future, I'm now creating this PR.