diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 96e946407a..f40e93d4a3 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -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; @@ -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; diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index 3dac09af92..edfa04d482 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -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) { @@ -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); diff --git a/libraries/protocol/steem_operations.cpp b/libraries/protocol/steem_operations.cpp index 5bddf56fcd..deb5fb9ff3 100644 --- a/libraries/protocol/steem_operations.cpp +++ b/libraries/protocol/steem_operations.cpp @@ -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 {