@@ -1991,8 +1991,7 @@ namespace golos {
19911991 claim_rshare_reward (
19921992 comment.net_rshares ,
19931993 comment.reward_weight ,
1994- to_steem (comment.max_accepted_payout ),
1995- comment.curve ));
1994+ to_steem (comment.max_accepted_payout )));
19961995
19971996 asset total_payout;
19981997 if (reward_tokens > 0 ) {
@@ -2061,7 +2060,7 @@ namespace golos {
20612060
20622061 }
20632062
2064- fc::uint128_t old_rshares2 = calculate_vshares (comment.net_rshares .value , comment. curve );
2063+ fc::uint128_t old_rshares2 = calculate_vshares (comment.net_rshares .value );
20652064 adjust_rshares2 (comment, old_rshares2, 0 );
20662065 }
20672066
@@ -2430,14 +2429,11 @@ namespace golos {
24302429 return (rshares + s) * (rshares + s) - s * s;
24312430 }
24322431
2433- uint128_t database::calculate_vshares (uint128_t rshares, reward_curve curve) const {
2434- switch (curve) {
2435- case reward_curve::linear:
2436- return calculate_vshares_linear (rshares);
2437-
2438- case reward_curve::quadratic:
2439- default :
2440- return calculate_vshares_quadratic (rshares, get_content_constant_s ());
2432+ uint128_t database::calculate_vshares (uint128_t rshares) const {
2433+ if (has_hardfork (STEEMIT_HARDFORK_0_17__433 )) {
2434+ return calculate_vshares_linear (rshares);
2435+ } else {
2436+ return calculate_vshares_quadratic (rshares, get_content_constant_s ());
24412437 }
24422438 }
24432439
@@ -2510,9 +2506,7 @@ namespace golos {
25102506 * This method reduces the rshare^2 supply and returns the number of tokens are
25112507 * redeemed.
25122508 */
2513- share_type database::claim_rshare_reward (
2514- share_type rshares, uint16_t reward_weight, asset max_steem, reward_curve curve
2515- ) {
2509+ share_type database::claim_rshare_reward (share_type rshares, uint16_t reward_weight, asset max_steem) {
25162510 try {
25172511 FC_ASSERT (rshares > 0 );
25182512
@@ -2522,7 +2516,7 @@ namespace golos {
25222516 u256 rf (props.total_reward_fund_steem .amount .value );
25232517 u256 total_rshares2 = to256 (props.total_reward_shares2 );
25242518
2525- u256 rs2 = to256 (calculate_vshares (rshares.value , curve ));
2519+ u256 rs2 = to256 (calculate_vshares (rshares.value ));
25262520 rs2 = (rs2 * reward_weight) / STEEMIT_100_PERCENT ;
25272521
25282522 u256 payout_u256 = (rf * rs2) / total_rshares2;
@@ -4260,6 +4254,15 @@ namespace golos {
42604254 const auto &by_root_idx = get_index<comment_index, by_root>();
42614255 const auto max_cashout_time = head_block_time ();
42624256
4257+ auto recalc_rshares2 = [&](const comment_object &c) {
4258+ if (c.net_rshares .value > 0 ) {
4259+ auto old_rshares2 = calculate_vshares_quadratic (
4260+ c.net_rshares .value , get_content_constant_s ());
4261+ auto new_rshares2 = calculate_vshares_linear (c.net_rshares .value );
4262+ adjust_rshares2 (c, old_rshares2, new_rshares2);
4263+ }
4264+ };
4265+
42634266 std::vector<comment_object::id_type> root_posts;
42644267 root_posts.reserve (STEEMIT_HF_17_NUM_POSTS );
42654268
@@ -4279,12 +4282,16 @@ namespace golos {
42794282 c.cashout_time = std::max (c.created + STEEMIT_CASHOUT_WINDOW_SECONDS , max_cashout_time);
42804283 });
42814284
4285+ recalc_rshares2 (*itr);
4286+
42824287 auto reply_itr = by_root_idx.lower_bound (id);
42834288 for (; reply_itr != by_root_idx.end () && reply_itr->root_comment == id; ++reply_itr) {
42844289 modify (*reply_itr, [&](comment_object &c) {
42854290 // limit second cashout window to 1 week, or a current block time
42864291 c.cashout_time = std::max (c.created + STEEMIT_CASHOUT_WINDOW_SECONDS , max_cashout_time);
42874292 });
4293+
4294+ recalc_rshares2 (*reply_itr);
42884295 }
42894296 }}
42904297 break ;
@@ -4411,7 +4418,7 @@ namespace golos {
44114418 for (auto itr = comment_idx.begin ();
44124419 itr != comment_idx.end (); ++itr) {
44134420 if (itr->net_rshares .value > 0 ) {
4414- auto delta = calculate_vshares (itr->net_rshares .value , itr-> curve );
4421+ auto delta = calculate_vshares (itr->net_rshares .value );
44154422 total_rshares2 += delta;
44164423 }
44174424 if (itr->parent_author == STEEMIT_ROOT_POST_PARENT ) {
@@ -4486,7 +4493,7 @@ namespace golos {
44864493
44874494 for (const auto &c : comments) {
44884495 if (c.net_rshares .value > 0 ) {
4489- adjust_rshares2 (c, 0 , calculate_vshares (c.net_rshares .value , c. curve ));
4496+ adjust_rshares2 (c, 0 , calculate_vshares (c.net_rshares .value ));
44904497 }
44914498 }
44924499
0 commit comments