diff --git a/libraries/api/chain_api_properties.cpp b/libraries/api/chain_api_properties.cpp index 74c85d0d8a..dc3cd95d53 100644 --- a/libraries/api/chain_api_properties.cpp +++ b/libraries/api/chain_api_properties.cpp @@ -19,6 +19,10 @@ namespace golos { namespace api { max_referral_interest_rate = src.max_referral_interest_rate; max_referral_term_sec = src.max_referral_term_sec; max_referral_break_fee = src.max_referral_break_fee; + comments_capacity_100 = src.comments_capacity_100; + comment_consumption = src.comment_consumption; + voting_capacity_100 = src.voting_capacity_100; + voting_consumption = src.voting_consumption; } } diff --git a/libraries/api/include/golos/api/chain_api_properties.hpp b/libraries/api/include/golos/api/chain_api_properties.hpp index 401c86a856..d2f918a47f 100644 --- a/libraries/api/include/golos/api/chain_api_properties.hpp +++ b/libraries/api/include/golos/api/chain_api_properties.hpp @@ -24,6 +24,11 @@ namespace golos { namespace api { fc::optional max_referral_interest_rate; fc::optional max_referral_term_sec; fc::optional max_referral_break_fee; + + fc::optional comments_capacity_100; + fc::optional comment_consumption; + fc::optional voting_capacity_100; + fc::optional voting_consumption; }; } } // golos::api @@ -33,4 +38,5 @@ FC_REFLECT( (account_creation_fee)(maximum_block_size)(sbd_interest_rate) (create_account_min_golos_fee)(create_account_min_delegation) (create_account_delegation_time)(min_delegation) - (max_referral_interest_rate)(max_referral_term_sec)(max_referral_break_fee)) + (max_referral_interest_rate)(max_referral_term_sec)(max_referral_break_fee) + (comments_capacity_100)(comment_consumption)(voting_capacity_100)(voting_consumption)) diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 89699a8847..e3058906fd 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -1898,6 +1898,10 @@ 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(&chain_properties_19::comments_capacity_100); + calc_median(&chain_properties_19::comment_consumption); + calc_median(&chain_properties_19::voting_capacity_100); + calc_median(&chain_properties_19::voting_consumption); 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 3c337107dd..be1ed29d68 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -527,6 +527,8 @@ namespace golos { namespace chain { logic_exception::cannot_update_comment_because_nothing_changed, "Cannot update comment because nothing appears to be changing."); + const auto& mprops = _db.get_witness_schedule_object().median_props; + const auto &by_permlink_idx = _db.get_index().indices().get(); auto itr = by_permlink_idx.find(boost::make_tuple(o.author, o.permlink)); @@ -571,8 +573,9 @@ namespace golos { namespace chain { } int64_t elapsed_seconds = (now - auth.last_post).to_seconds(); - int64_t regenerated_capacity = std::min(int64_t(STEEMIT_COMMENTS_CAPACITY_100), int64_t(elapsed_seconds)); - int64_t current_capacity = std::min(int64_t(auth.comments_capacity + regenerated_capacity), int64_t(STEEMIT_COMMENTS_CAPACITY_100)); + int64_t regenerated_capacity = std::min(int64_t(mprops.comments_capacity_100), int64_t(elapsed_seconds)); + int64_t current_capacity = std::min(int64_t(auth.comments_capacity + regenerated_capacity), + int64_t(mprops.comments_capacity_100)); if (_db.has_hardfork(STEEMIT_HARDFORK_0_19__533)) { if (o.parent_author == STEEMIT_ROOT_POST_PARENT) { @@ -580,10 +583,10 @@ namespace golos { namespace chain { bandwidth_exception::post_bandwidth, "You may only post once every 5 minutes."); } else { - GOLOS_CHECK_BANDWIDTH(current_capacity, STEEMIT_COMMENT_CONSUMPTION, + GOLOS_CHECK_BANDWIDTH(current_capacity, mprops.comment_consumption, bandwidth_exception::comment_bandwidth, - "You may only comment " + std::to_string(STEEMIT_COMMENTS_CAPACITY_100 / STEEMIT_COMMENT_CONSUMPTION) - + " times in " + std::to_string(STEEMIT_COMMENTS_CAPACITY_100) + " seconds."); + "You may only comment " + std::to_string(mprops.comments_capacity_100 / mprops.comment_consumption) + + " times in " + std::to_string(mprops.comments_capacity_100) + " seconds."); } } else if (_db.has_hardfork(STEEMIT_HARDFORK_0_12__176)) { if (o.parent_author == STEEMIT_ROOT_POST_PARENT) @@ -639,7 +642,10 @@ namespace golos { namespace chain { db().modify(auth, [&](account_object &a) { a.last_post = now; a.post_count++; - a.comments_capacity = uint16_t(current_capacity - STEEMIT_COMMENT_CONSUMPTION); + if (o.parent_author != STEEMIT_ROOT_POST_PARENT) { + a.comment_count++; + } + a.comments_capacity = uint16_t(current_capacity - mprops.comment_consumption); }); _db.create([&](comment_object &com) { @@ -1185,6 +1191,8 @@ namespace golos { namespace chain { const auto& comment = _db.get_comment(o.author, o.permlink); const auto& voter = _db.get_account(o.voter); + const auto& mprops = _db.get_witness_schedule_object().median_props; + GOLOS_CHECK_LOGIC(!(voter.owner_challenged || voter.active_challenged), logic_exception::account_is_currently_challenged, "Account \"${account}\" is currently challenged", ("account", voter.name)); @@ -1222,14 +1230,14 @@ namespace golos { namespace chain { auto itr = comment_vote_idx.find(std::make_tuple(comment.id, voter.id)); int64_t elapsed_seconds = (_db.head_block_time() - voter.last_vote_time).to_seconds(); - int64_t regenerated_capacity = std::min(int64_t(STEEMIT_VOTING_CAPACITY_100), int64_t(elapsed_seconds)); - int64_t current_capacity = std::min(int64_t(voter.voting_capacity + regenerated_capacity), int64_t(STEEMIT_VOTING_CAPACITY_100)); + int64_t regenerated_capacity = std::min(int64_t(mprops.voting_capacity_100), int64_t(elapsed_seconds)); + int64_t current_capacity = std::min(int64_t(voter.voting_capacity + regenerated_capacity), int64_t(mprops.voting_capacity_100)); if (_db.has_hardfork(STEEMIT_HARDFORK_0_19__533)) { - GOLOS_CHECK_BANDWIDTH(current_capacity, STEEMIT_VOTING_CONSUMPTION, + GOLOS_CHECK_BANDWIDTH(current_capacity, mprops.voting_consumption, bandwidth_exception::vote_bandwidth, - "Can only vote " + std::to_string(STEEMIT_VOTING_CAPACITY_100 / STEEMIT_VOTING_CONSUMPTION) - + " times in " + std::to_string(STEEMIT_VOTING_CAPACITY_100) + " seconds."); + "Can only vote " + std::to_string(mprops.voting_capacity_100 / mprops.voting_consumption) + + " times in " + std::to_string(mprops.voting_capacity_100) + " seconds."); } else { GOLOS_CHECK_BANDWIDTH(_db.head_block_time(), voter.last_vote_time + STEEMIT_MIN_VOTE_INTERVAL_SEC-1, bandwidth_exception::vote_bandwidth, "Can only vote once every 3 seconds."); @@ -1298,7 +1306,7 @@ namespace golos { namespace chain { _db.modify(voter, [&](account_object &a) { a.voting_power = current_power - used_power; a.last_vote_time = _db.head_block_time(); - a.voting_capacity = uint16_t(current_capacity - STEEMIT_VOTING_CONSUMPTION); + a.voting_capacity = uint16_t(current_capacity - mprops.voting_consumption); }); /// if the current net_rshares is less than 0, the post is getting 0 rewards so it is not factored into total rshares^2 diff --git a/libraries/protocol/include/golos/protocol/steem_operations.hpp b/libraries/protocol/include/golos/protocol/steem_operations.hpp index 8b5fd216fd..59db631f1d 100644 --- a/libraries/protocol/include/golos/protocol/steem_operations.hpp +++ b/libraries/protocol/include/golos/protocol/steem_operations.hpp @@ -517,6 +517,26 @@ namespace golos { namespace protocol { */ asset max_referral_break_fee = GOLOS_DEFAULT_REFERRAL_BREAK_FEE; + /** + * Total bandwidth battery capacity for comments + */ + uint16_t comments_capacity_100 = STEEMIT_COMMENTS_CAPACITY_100; + + /** + * Consumption of bandwidth battery by each comment + */ + uint16_t comment_consumption = STEEMIT_COMMENT_CONSUMPTION; + + /** + * Total bandwidth battery capacity for votes + */ + uint16_t voting_capacity_100 = STEEMIT_VOTING_CAPACITY_100; + + /** + * Consumption of bandwidth battery by each vote + */ + uint16_t voting_consumption = STEEMIT_VOTING_CONSUMPTION; + void validate() const; chain_properties_19& operator=(const chain_properties_17& src) { @@ -1178,7 +1198,8 @@ FC_REFLECT_DERIVED( (create_account_delegation_time)(min_delegation)) FC_REFLECT_DERIVED( (golos::protocol::chain_properties_19), ((golos::protocol::chain_properties_18)), - (max_referral_interest_rate)(max_referral_term_sec)(max_referral_break_fee)) + (max_referral_interest_rate)(max_referral_term_sec)(max_referral_break_fee) + (comments_capacity_100)(comment_consumption)(voting_capacity_100)(voting_consumption)) FC_REFLECT_TYPENAME((golos::protocol::versioned_chain_properties)) diff --git a/libraries/wallet/include/golos/wallet/wallet.hpp b/libraries/wallet/include/golos/wallet/wallet.hpp index 0fe3175bb4..6000fc12b0 100644 --- a/libraries/wallet/include/golos/wallet/wallet.hpp +++ b/libraries/wallet/include/golos/wallet/wallet.hpp @@ -48,6 +48,11 @@ namespace golos { namespace wallet { fc::optional max_referral_interest_rate; fc::optional max_referral_term_sec; fc::optional max_referral_break_fee; + + fc::optional comments_capacity_100; + fc::optional comment_consumption; + fc::optional voting_capacity_100; + fc::optional voting_consumption; }; struct optional_private_box_query { @@ -1493,7 +1498,8 @@ FC_REFLECT((golos::wallet::optional_chain_props), (account_creation_fee)(maximum_block_size)(sbd_interest_rate) (create_account_min_golos_fee)(create_account_min_delegation) (create_account_delegation_time)(min_delegation) - (max_referral_interest_rate)(max_referral_term_sec)(max_referral_break_fee)) + (max_referral_interest_rate)(max_referral_term_sec)(max_referral_break_fee) + (comments_capacity_100)(comment_consumption)(voting_capacity_100)(voting_consumption)) FC_REFLECT( (golos::wallet::message_body), diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 86814be00a..c003a7d8d8 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -330,6 +330,10 @@ namespace golos { namespace wallet { result["max_referral_interest_rate"] = median_props.max_referral_interest_rate; result["max_referral_term_sec"] = median_props.max_referral_term_sec; result["max_referral_break_fee"] = median_props.max_referral_break_fee; + result["comments_capacity_100"] = median_props.comments_capacity_100; + result["comment_consumption"] = median_props.comment_consumption; + result["voting_capacity_100"] = median_props.voting_capacity_100; + result["voting_consumption"] = median_props.voting_consumption; } return result; @@ -2194,6 +2198,10 @@ fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_st SET_PROP(max_referral_interest_rate); SET_PROP(max_referral_term_sec); SET_PROP(max_referral_break_fee); + SET_PROP(comments_capacity_100); + SET_PROP(comment_consumption); + SET_PROP(voting_capacity_100); + SET_PROP(voting_consumption); #undef SET_PROP op.owner = witness_account_name;