Skip to content

Commit

Permalink
correction remarks #353
Browse files Browse the repository at this point in the history
  • Loading branch information
kudzinp committed Feb 4, 2019
1 parent f86533f commit af97026
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
37 changes: 19 additions & 18 deletions golos.publication/golos.publication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ int64_t publication::pay_curators(name author, uint64_t msgid, int64_t max_rewar
eosio_assert(claim <= unclaimed_rewards, "LOGIC ERROR! publication::pay_curators: claim > unclaimed_rewards");
if(claim > 0) {
unclaimed_rewards -= claim;
claim -= pay_delegators(msgid, claim, v->voter, tokensymbol);
claim -= pay_delegators(msgid, claim, v->voter, tokensymbol, v->delegators);
payto(v->voter, eosio::asset(claim, tokensymbol), static_cast<enum_t>(payment_t::VESTING));
}
}
Expand Down Expand Up @@ -616,7 +616,8 @@ void publication::set_vote(name voter, name author, string permlink, int16_t wei
auto token_code = pool->state.funds.symbol.code();
auto list_delegate_voter = golos::vesting::get_list_delegate(config::vesting_name, voter, token_code);
for (auto record : list_delegate_voter)
delegators.push_back( {record.sender, record.quantity} );
delegators.push_back( {record.sender, record.quantity, record.interest_rate,
record.payout_strategy, weight} );

vote_table.emplace(voter, [&]( auto &item ) {
item.id = vote_table.available_primary_key();
Expand Down Expand Up @@ -810,27 +811,27 @@ void publication::reblog(name rebloger, name author, std::string permlink) {
"You can't reblog, because this message doesn't exist.");
}

int64_t publication::pay_delegators(uint64_t message_id, int64_t claim, name voter, eosio::symbol tokensymbol) {
int64_t publication::pay_delegators(uint64_t message_id, int64_t claim, name voter,
eosio::symbol tokensymbol, std::vector<structures::delegate_voter> delegate_list) {
int64_t dlg_payout_sum = 0;
auto delegate_list = golos::vesting::get_list_delegate(config::vesting_name, voter, tokensymbol.code());
for (auto delegate_obj : delegate_list) {
tables::delegate_table table(_self, tokensymbol.code().raw());
auto index_table = table.get_index<"unique"_n>();
auto delegate_record = index_table.find(structures::delegate_record::unique_key(delegate_obj.sender, voter));
if (delegate_record != index_table.end()) {
if (delegate_record->payout_strategy == config::to_delegated_vesting) {
auto dlg_payout = claim * delegate_record->interest_rate / config::_100percent;
tables::account_table acc_table(_self, voter.value);
auto balance = acc_table.find(tokensymbol.code().raw());
acc_table.modify(balance, delegate_obj.sender, [&](auto& item) {
item.delegate_vesting += eosio::asset(dlg_payout, tokensymbol);
item.received_vesting += eosio::asset(dlg_payout, tokensymbol);
});
if (delegate_obj.payout_strategy == config::to_delegated_vesting) {
auto dlg_payout = claim * delegate_obj.interest_rate / config::_100percent;
tables::account_table acc_table(_self, voter.value);
auto balance = acc_table.find(tokensymbol.code().raw());
acc_table.modify(balance, delegate_obj.delegator, [&](auto& item) {
item.delegate_vesting += eosio::asset(dlg_payout, tokensymbol);
item.received_vesting += eosio::asset(dlg_payout, tokensymbol);
});
tables::delegate_table table(_self, tokensymbol.code().raw());
auto index_table = table.get_index<"unique"_n>();
auto delegate_record = index_table.find(structures::delegate_record::unique_key(delegate_obj.delegator, voter));
if (delegate_record != index_table.end()) {
index_table.modify(delegate_record, name(), [&](auto& item) {
item.deductions += eosio::asset(dlg_payout, tokensymbol);
});
dlg_payout_sum += dlg_payout;
});
}
dlg_payout_sum += dlg_payout;
}
}
return dlg_payout_sum;
Expand Down
3 changes: 2 additions & 1 deletion golos.publication/golos.publication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class publication : public contract {
symbol tokensymbol);
void payto(name user, asset quantity, enum_t mode);
void check_account(name user, symbol tokensymbol);
int64_t pay_delegators(uint64_t message_id, int64_t claim, name voter, eosio::symbol tokensymbol);
int64_t pay_delegators(uint64_t message_id, int64_t claim, name voter,
eosio::symbol tokensymbol, std::vector<structures::delegate_voter> delegate_list);

void send_poolstate_event(const structures::rewardpool& pool);
void send_poolerase_event(const structures::rewardpool& pool);
Expand Down
3 changes: 3 additions & 0 deletions golos.publication/objects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ struct delegate_voter {

name delegator;
asset quantity;
uint64_t interest_rate;
uint8_t payout_strategy;
int16_t weight;
};

struct voteinfo {
Expand Down

0 comments on commit af97026

Please sign in to comment.