Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Fix #533
Browse files Browse the repository at this point in the history
  • Loading branch information
maslenitsa93 committed Sep 17, 2018
1 parent d340841 commit 6b77bdb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
17 changes: 8 additions & 9 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1892,13 +1892,14 @@ namespace golos { namespace chain {
std::nth_element(
active.begin(), active.begin() + active.size() / 2, active.end(),
[&](const auto* a, const auto* b) {
return a->props.*window / a->props.*items <
b->props.*window / b->props.*items;
auto a_consumption = a->props.*window / a->props.*items;
auto b_consumption = b->props.*window / b->props.*items;
return std::tie(a_consumption, a->props.*items) <
std::tie(b_consumption, b->props.*items);
}
);
auto* median = active[active.size() / 2];
std::tie(median_props.*window, median_props.*items) =
std::tie(median->props.*window, median->props.*items);
median_props.*window = active[active.size() / 2]->props.*window;
median_props.*items = active[active.size() / 2]->props.*items;
};

calc_median(&chain_properties_17::account_creation_fee);
Expand All @@ -1911,10 +1912,8 @@ namespace golos { namespace chain {
calc_median(&chain_properties_19::max_referral_interest_rate);
calc_median(&chain_properties_19::max_referral_term_sec);
calc_median(&chain_properties_19::max_referral_break_fee);
calc_median_battery(&chain_properties_19::comments_window,
&chain_properties_19::comments_per_window);
calc_median_battery(&chain_properties_19::votes_window,
&chain_properties_19::votes_per_window);
calc_median_battery(&chain_properties_19::comments_window, &chain_properties_19::comments_per_window);
calc_median_battery(&chain_properties_19::votes_window, &chain_properties_19::votes_per_window);

modify(wso, [&](witness_schedule_object &_wso) {
_wso.median_props = median_props;
Expand Down
12 changes: 6 additions & 6 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,10 @@ namespace golos { namespace chain {
auto elapsed_seconds = (now - auth.last_post).to_seconds();

if (_db.has_hardfork(STEEMIT_HARDFORK_0_19__533)) {
auto consumption = mprops.comments_window / mprops.comments_per_window;
auto consumption = uint16_t(mprops.comments_window / mprops.comments_per_window);

auto regenerated_capacity = std::min(mprops.comments_window, uint16_t(elapsed_seconds));
auto current_capacity = std::min(uint16_t(auth.comments_capacity + regenerated_capacity), mprops.comments_window);
auto regenerated_capacity = std::min(uint32_t(mprops.comments_window), uint32_t(elapsed_seconds));
auto current_capacity = std::min(uint32_t(auth.comments_capacity + regenerated_capacity), uint32_t(mprops.comments_window));

if (o.parent_author == STEEMIT_ROOT_POST_PARENT) {
GOLOS_CHECK_BANDWIDTH(now, band->last_bandwidth_update + STEEMIT_MIN_ROOT_COMMENT_INTERVAL,
Expand Down Expand Up @@ -1238,10 +1238,10 @@ namespace golos { namespace chain {
auto elapsed_seconds = (_db.head_block_time() - voter.last_vote_time).to_seconds();

if (_db.has_hardfork(STEEMIT_HARDFORK_0_19__533)) {
auto consumption = mprops.comments_window / mprops.comments_per_window;
auto consumption = uint16_t(mprops.comments_window / mprops.comments_per_window);

auto regenerated_capacity = std::min(mprops.votes_window, uint16_t(elapsed_seconds));
auto current_capacity = std::min(uint16_t(voter.voting_capacity + regenerated_capacity), mprops.comments_window);
auto regenerated_capacity = std::min(uint32_t(mprops.votes_window), uint32_t(elapsed_seconds));
auto current_capacity = std::min(uint32_t(voter.voting_capacity + regenerated_capacity), uint32_t(mprops.comments_window));

GOLOS_CHECK_BANDWIDTH(current_capacity, consumption,
bandwidth_exception::vote_bandwidth,
Expand Down

0 comments on commit 6b77bdb

Please sign in to comment.