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

Commit

Permalink
Merge pull request #1368 from GolosChain/1367-delegate-vesting-shares…
Browse files Browse the repository at this point in the history
…-interest-rate-bug

Fix delegate_vesting_shares interest_rate checking #1367
  • Loading branch information
afalaleev authored Jul 27, 2019
2 parents 44a533a + 678e01d commit 7eef021
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2580,14 +2580,14 @@ namespace {
template <typename Operation>
void delegate_vesting_shares(
database& _db, const chain_properties& median_props, const Operation& op,
const delegate_vesting_shares_with_interest_extensions_type* extensions, uint16_t interest_rate
const delegate_vesting_shares_with_interest_extensions_type* extensions, fc::optional<uint16_t> interest_rate
) {
const auto& delegator = _db.get_account(op.delegator);
const auto& delegatee = _db.get_account(op.delegatee);
auto delegation = _db.find<vesting_delegation_object, by_delegation>(std::make_tuple(op.delegator, op.delegatee));

if (delegation) {
GOLOS_CHECK_LOGIC(delegation->interest_rate == interest_rate,
if (delegation && !!interest_rate) {
GOLOS_CHECK_LOGIC(delegation->interest_rate == *interest_rate,
logic_exception::cannot_change_delegator_interest_rate,
"Cannot change interest rate of already created delegation");
}
Expand Down Expand Up @@ -2647,7 +2647,9 @@ void delegate_vesting_shares(
o.delegatee = op.delegatee;
o.vesting_shares = op.vesting_shares;
o.min_delegation_time = now;
o.interest_rate = interest_rate;
if (!!interest_rate) {
o.interest_rate = *interest_rate;
}
});
} else {
_db.modify(*delegation, [&](vesting_delegation_object& o) {
Expand Down Expand Up @@ -2698,7 +2700,7 @@ void delegate_vesting_shares(
void delegate_vesting_shares_evaluator::do_apply(const delegate_vesting_shares_operation& op) {
const auto& median_props = _db.get_witness_schedule_object().median_props;

delegate_vesting_shares(_db, median_props, op, nullptr, 0);
delegate_vesting_shares(_db, median_props, op, nullptr, fc::optional<uint16_t>());
}

void break_free_referral_evaluator::do_apply(const break_free_referral_operation& op) {
Expand Down Expand Up @@ -2730,7 +2732,7 @@ void delegate_vesting_shares(

GOLOS_CHECK_LIMIT_PARAM(op.interest_rate, median_props.max_delegated_vesting_interest_rate);

delegate_vesting_shares(_db, median_props, op, &op.extensions, op.interest_rate);
delegate_vesting_shares(_db, median_props, op, &op.extensions, fc::optional<uint16_t>(op.interest_rate));
}

void reject_vesting_shares_delegation_evaluator::do_apply(const reject_vesting_shares_delegation_operation& op) {
Expand Down

0 comments on commit 7eef021

Please sign in to comment.