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

Commit

Permalink
Made auction window votable. Fixed rewards calculations. #898
Browse files Browse the repository at this point in the history
  • Loading branch information
AKorpusenko committed Aug 23, 2018
1 parent 7b97d9a commit c881c09
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
4 changes: 4 additions & 0 deletions libraries/api/discussion_helper.cpp
Expand Up @@ -112,6 +112,7 @@ namespace golos { namespace api {
d.allow_replies = o.allow_replies;
d.allow_votes = o.allow_votes;
d.allow_curation_rewards = o.allow_curation_rewards;
d.auction_window_weight = o.auction_window_weight;

for (auto& route : o.beneficiaries) {
d.beneficiaries.push_back(route);
Expand Down Expand Up @@ -191,6 +192,9 @@ namespace golos { namespace api {
break;
}
}

auto reward_fund_claim = ((max_rewards.value * d.auction_window_weight) / total_weight).to_uint64();

This comment has been minimized.

Copy link
@afalaleev

afalaleev Aug 24, 2018

Member

d.auction_window_weight -> uint128_t

unclaimed_rewards -= reward_fund_claim;
}
} else {
unclaimed_rewards = 0;
Expand Down
2 changes: 2 additions & 0 deletions libraries/api/include/golos/api/comment_api_object.hpp
Expand Up @@ -61,6 +61,8 @@ namespace golos { namespace api {
comment_mode mode = not_set;

comment_object::id_type root_comment;

uint64_t auction_window_weight = 0;

string root_title;

Expand Down
10 changes: 9 additions & 1 deletion libraries/chain/database.cpp
Expand Up @@ -1895,7 +1895,7 @@ namespace golos { namespace chain {
calc_median(&chain_properties_18::create_account_min_delegation);
calc_median(&chain_properties_18::create_account_delegation_time);
calc_median(&chain_properties_18::min_delegation);
calc_median(&chain_properties_19::reverse_auction_window_size);
calc_median(&chain_properties_19::auction_window_size);

modify(wso, [&](witness_schedule_object &_wso) {
_wso.median_props = median_props;
Expand Down Expand Up @@ -2285,6 +2285,14 @@ namespace golos { namespace chain {
unclaimed_rewards = 0;
}

if (c.total_vote_weight > 0 && c.allow_curation_rewards) {

This comment has been minimized.

Copy link
@afalaleev

afalaleev Aug 24, 2018

Member

else if (c.total_vote_weight > 0) {

auto reward_fund_claim = ((max_rewards.value * c.auction_window_weight) / total_weight).to_uint64();

This comment has been minimized.

Copy link
@afalaleev

afalaleev Aug 24, 2018

Member

c.auction_window_weight - > uint128_t

unclaimed_rewards -= reward_fund_claim;
modify(get_dynamic_global_properties(), [&](dynamic_global_property_object &props) {
props.total_reward_fund_steem += asset(reward_fund_claim, STEEM_SYMBOL);
});
}

return unclaimed_rewards;
} FC_CAPTURE_AND_RETHROW()
}
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/include/golos/chain/comment_object.hpp
Expand Up @@ -89,6 +89,8 @@ namespace golos {

id_type root_comment;

uint64_t auction_window_weight = 0;

comment_mode mode = first_payout;

asset max_accepted_payout = asset(1000000000, SBD_SYMBOL); /// SBD value of the maximum payout this post will receive
Expand Down
13 changes: 10 additions & 3 deletions libraries/chain/steem_evaluator.cpp
Expand Up @@ -1426,16 +1426,23 @@ namespace golos { namespace chain {

if (_db.head_block_time() >
fc::time_point_sec(STEEMIT_HARDFORK_0_6_REVERSE_AUCTION_TIME)) /// start enforcing this prior to the hardfork
{
{

This comment has been minimized.

Copy link
@afalaleev

afalaleev Aug 24, 2018

Member

???

/// discount weight by time
const witness_schedule_object &wso = _db.get_witness_schedule_object();

This comment has been minimized.

Copy link
@afalaleev

afalaleev Aug 24, 2018

Member

const witness_schedule_object& wso

const auto &auction_window = wso.median_props.auction_window_size;

This comment has been minimized.

Copy link
@afalaleev

afalaleev Aug 24, 2018

Member

const auto& auction_window


uint128_t w(max_vote_weight);
uint64_t delta_t = std::min(uint64_t((
cv.last_update -
comment.created).to_seconds()), uint64_t(STEEMIT_REVERSE_AUCTION_WINDOW_SECONDS));
comment.created).to_seconds()), uint64_t(auction_window));

w *= delta_t;
w /= STEEMIT_REVERSE_AUCTION_WINDOW_SECONDS;
w /= auction_window;
cv.weight = w.to_uint64();

_db.modify(comment, [&](comment_object &o) {
o.auction_window_weight += max_vote_weight - w.to_uint64();
});
}
} else {
cv.weight = 0;
Expand Down
14 changes: 8 additions & 6 deletions libraries/protocol/include/golos/protocol/steem_operations.hpp
Expand Up @@ -493,7 +493,7 @@ namespace golos { namespace protocol {
sbd_interest_rate = src.sbd_interest_rate;
return *this;
}

chain_properties_18& operator=(const chain_properties_18&) = default;

chain_properties_18& operator=(const chain_properties_19& src);
Expand All @@ -504,7 +504,7 @@ namespace golos { namespace protocol {
/**
* Голосуемый параметр. Штрафное окно голосования
*/
uint32_t reverse_auction_window_size = STEEMIT_REVERSE_AUCTION_WINDOW_SECONDS;
uint32_t auction_window_size = STEEMIT_REVERSE_AUCTION_WINDOW_SECONDS;


void validate() const;
Expand All @@ -517,13 +517,15 @@ namespace golos { namespace protocol {
}

chain_properties_19& operator=(const chain_properties_18& src) {
// 18
create_account_min_golos_fee = src.create_account_min_golos_fee;
create_account_min_delegation = src.create_account_min_delegation;
create_account_delegation_time = src.create_account_delegation_time;
min_delegation = src.min_delegation;
// account_creation_fee = src.account_creation_fee;
// maximum_block_size = src.maximum_block_size;
// sbd_interest_rate = src.sbd_interest_rate;
// 17
account_creation_fee = src.account_creation_fee;
maximum_block_size = src.maximum_block_size;
sbd_interest_rate = src.sbd_interest_rate;
return *this;
}

Expand Down Expand Up @@ -1189,7 +1191,7 @@ FC_REFLECT_DERIVED(
(create_account_delegation_time)(min_delegation))
FC_REFLECT_DERIVED(
(golos::protocol::chain_properties_19),((golos::protocol::chain_properties_18)),
(reverse_auction_window_size))
(auction_window_size))

FC_REFLECT_TYPENAME((golos::protocol::versioned_chain_properties))

Expand Down
2 changes: 1 addition & 1 deletion libraries/protocol/steem_operations.cpp
Expand Up @@ -228,7 +228,7 @@ namespace golos { namespace protocol {

void chain_properties_19::validate() const {
chain_properties_18::validate();
GOLOS_CHECK_VALUE_GT(reverse_auction_window_size, 0);
GOLOS_CHECK_VALUE_GT(auction_window_size, 0);
}

void witness_update_operation::validate() const {
Expand Down

0 comments on commit c881c09

Please sign in to comment.