-
Notifications
You must be signed in to change notification settings - Fork 647
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
BSIP 36 Candidate #832
BSIP 36 Candidate #832
Changes from 4 commits
2e1f07d
10c7e8f
101a02c
63199d0
f60a953
67e1ec4
c93913c
09b7ffb
bcea865
81bdfa3
960bfe9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -925,7 +925,29 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g | |
// Reset all BitAsset force settlement volumes to zero | ||
for( const auto& d : get_index_type<asset_bitasset_data_index>().indices() ) | ||
{ | ||
modify( d, [](asset_bitasset_data_object& o) { o.force_settled_volume = 0; }); | ||
if(head_block_time() < HARDFORK_CORE_518_TIME) | ||
modify( d, [](asset_bitasset_data_object& o) { o.force_settled_volume = 0; }); | ||
else { // clean expired feeds | ||
modify( d, [this](asset_bitasset_data_object& o) { | ||
o.force_settled_volume = 0; | ||
|
||
// Check if asset is smartcoin | ||
const auto& settlement_price = o.feeds.begin()->second.second.settlement_price; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not safe. Before dereferencing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. silly me, fixed here f60a953 thank you. |
||
if(!settlement_price.is_null()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is incorrect. The first feed is null doesn't mean all feeds are null. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #832 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. waiting for more comments from @pmconrad maybe. |
||
const auto &asset = get(settlement_price.base.asset_id); | ||
auto flags = asset.options.flags; | ||
if ((flags & witness_fed_asset) || (flags & committee_fed_asset)) { // if smartcoin | ||
for (auto itr = o.feeds.begin(); itr != o.feeds.end();) { // loop feeds | ||
auto feed_time = itr->second.first; | ||
if (feed_time + (o.options.feed_lifetime_sec) < head_block_time()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better performance, please calculate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done this one, checked for overflow only as we are dealing with all unsigned ints so underflow will not be possible. overflow could occur with a feed_lifetime_sec is too big. hard to happen in practice as when we are here we are in a smartcoin but check was added anyways. |
||
itr = o.feeds.erase(itr); // delete expired feed | ||
else | ||
++itr; | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
if( d.has_settlement() ) | ||
process_bids(d); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// bitshares-core issue #518 Clean up bitasset_data during maintenance | ||
#ifndef HARDFORK_CORE_518_TIME | ||
#define HARDFORK_CORE_518_TIME (fc::time_point_sec( 1600000000 )) | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a newline. |
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.
For better performance, please move this check out of the
for
loop.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.
done.