Skip to content
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

Bsip36: clear expired feeds on maintenance interval #889

Merged
merged 17 commits into from
May 7, 2018
Merged

Conversation

abitmore
Copy link
Member

@abitmore abitmore commented May 7, 2018

@abitmore abitmore added this to the 201805 - Consensus Changing Release milestone May 7, 2018
Copy link
Contributor

@jmjatlanta jmjatlanta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you for documenting your test thoroughly. I was able to follow along easily.

std::advance( itr, 1 );
if( feed_time < calculated )
o.feeds.erase( itr.base() ); // delete expired feed
}
Copy link
Contributor

@jmjatlanta jmjatlanta May 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you, but you could replace this with something like:

o.feeds.erase( 
    std::remove_if(o.feeds.begin(), o.feeds.end(),
        [calculated] (auto f) { return f.second.first < calculated; }),
    o.feeds.end());

(Untested, just typing out loud)

Copy link
Contributor

@jmjatlanta jmjatlanta May 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry. remove_if doesn't work for map (until perhaps C++20). Please ignore.


for( const auto& d : get_index_type<asset_bitasset_data_index>().indices() )
{
modify( d, [this,head_time,head_epoch_seconds,after_hf_core_518]( asset_bitasset_data_object &o )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in the capture list changes within the for-loop, it would be more efficient to pull the lambda creation out of the loop.

@@ -176,6 +176,9 @@ namespace graphene { namespace chain {
static const uint8_t space_id = implementation_ids;
static const uint8_t type_id = impl_asset_bitasset_data_type;

/// The asset this object belong to
asset_id_type asset_id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must bump GRAPHENE_CURRENT_DB_VERSION when modifying DB object structures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@abitmore abitmore merged commit 55c8170 into hardfork May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants