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 13, 2018
1 parent 208c949 commit b1a2603
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,11 +1888,12 @@ namespace golos { namespace chain {
median_props.*param = active[active.size() / 2]->props.*param;
};

auto calc_median_battery = [&](auto&& window, auto&& items, auto&& sort_by) {
auto calc_median_battery = [&](auto&& window, auto&& items) {
std::nth_element(
active.begin(), active.begin() + active.size() / 2, active.end(),
[&](const auto* a, const auto* b) {
return a->props.*sort_by < b->props.*sort_by;
return std::tie(a->props.*window, a->props.*items) <
std::tie(b->props.*window, b->props.*items);
}
);
median_props.*window = active[active.size() / 2]->props.*window;
Expand All @@ -1910,9 +1911,9 @@ namespace golos { namespace chain {
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, &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, &chain_properties_19::votes_window);
&chain_properties_19::votes_per_window);

modify(wso, [&](witness_schedule_object &_wso) {
_wso.median_props = median_props;
Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ namespace golos { namespace chain {
} else {
GOLOS_CHECK_BANDWIDTH(current_capacity, consumption,
bandwidth_exception::comment_bandwidth,
"You may only comment " + std::to_string(mprops.comments_per_window)
+ " times in " + std::to_string(mprops.comments_window) + " seconds.");
"You may only comment ${cpw} times in ${cw} seconds.",
("cpw", mprops.comments_per_window)("cw", mprops.comments_window));
}

db().modify(auth, [&](account_object &a) {
Expand Down Expand Up @@ -1245,8 +1245,8 @@ namespace golos { namespace chain {

GOLOS_CHECK_BANDWIDTH(current_capacity, consumption,
bandwidth_exception::vote_bandwidth,
"Can only vote " + std::to_string(mprops.votes_per_window)
+ " times in " + std::to_string(mprops.votes_window) + " seconds.");
"Can only vote ${vpw} times in ${vw} seconds.",
("cpw", mprops.votes_per_window)("cw", mprops.votes_window));

_db.modify(voter, [&](account_object &a) {
a.voting_capacity = uint16_t(current_capacity - consumption);
Expand Down
4 changes: 2 additions & 2 deletions libraries/protocol/steem_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ namespace golos { namespace protocol {
GOLOS_CHECK_VALUE_LE(max_referral_term_sec, GOLOS_MAX_REFERRAL_TERM_SEC);
GOLOS_CHECK_VALUE_LEGE(max_referral_break_fee.amount, 0, GOLOS_MAX_REFERRAL_BREAK_FEE.amount);
GOLOS_CHECK_VALUE_GE(comments_window, 1);
GOLOS_CHECK_VALUE_GE(comments_per_window, 1);
GOLOS_CHECK_VALUE_LEGE(comments_per_window, 1, comments_window);
GOLOS_CHECK_VALUE_GE(votes_window, 1);
GOLOS_CHECK_VALUE_GE(votes_per_window, 1);
GOLOS_CHECK_VALUE_LEGE(votes_per_window, 1, votes_window);
}

void witness_update_operation::validate() const {
Expand Down

0 comments on commit b1a2603

Please sign in to comment.