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

Commit 678e01d

Browse files
committed
Fix delegate_vesting_shares interest_rate checking #1367
1 parent 44a533a commit 678e01d

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

libraries/chain/steem_evaluator.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,14 +2580,14 @@ namespace {
25802580
template <typename Operation>
25812581
void delegate_vesting_shares(
25822582
database& _db, const chain_properties& median_props, const Operation& op,
2583-
const delegate_vesting_shares_with_interest_extensions_type* extensions, uint16_t interest_rate
2583+
const delegate_vesting_shares_with_interest_extensions_type* extensions, fc::optional<uint16_t> interest_rate
25842584
) {
25852585
const auto& delegator = _db.get_account(op.delegator);
25862586
const auto& delegatee = _db.get_account(op.delegatee);
25872587
auto delegation = _db.find<vesting_delegation_object, by_delegation>(std::make_tuple(op.delegator, op.delegatee));
25882588

2589-
if (delegation) {
2590-
GOLOS_CHECK_LOGIC(delegation->interest_rate == interest_rate,
2589+
if (delegation && !!interest_rate) {
2590+
GOLOS_CHECK_LOGIC(delegation->interest_rate == *interest_rate,
25912591
logic_exception::cannot_change_delegator_interest_rate,
25922592
"Cannot change interest rate of already created delegation");
25932593
}
@@ -2647,7 +2647,9 @@ void delegate_vesting_shares(
26472647
o.delegatee = op.delegatee;
26482648
o.vesting_shares = op.vesting_shares;
26492649
o.min_delegation_time = now;
2650-
o.interest_rate = interest_rate;
2650+
if (!!interest_rate) {
2651+
o.interest_rate = *interest_rate;
2652+
}
26512653
});
26522654
} else {
26532655
_db.modify(*delegation, [&](vesting_delegation_object& o) {
@@ -2698,7 +2700,7 @@ void delegate_vesting_shares(
26982700
void delegate_vesting_shares_evaluator::do_apply(const delegate_vesting_shares_operation& op) {
26992701
const auto& median_props = _db.get_witness_schedule_object().median_props;
27002702

2701-
delegate_vesting_shares(_db, median_props, op, nullptr, 0);
2703+
delegate_vesting_shares(_db, median_props, op, nullptr, fc::optional<uint16_t>());
27022704
}
27032705

27042706
void break_free_referral_evaluator::do_apply(const break_free_referral_operation& op) {
@@ -2730,7 +2732,7 @@ void delegate_vesting_shares(
27302732

27312733
GOLOS_CHECK_LIMIT_PARAM(op.interest_rate, median_props.max_delegated_vesting_interest_rate);
27322734

2733-
delegate_vesting_shares(_db, median_props, op, &op.extensions, op.interest_rate);
2735+
delegate_vesting_shares(_db, median_props, op, &op.extensions, fc::optional<uint16_t>(op.interest_rate));
27342736
}
27352737

27362738
void reject_vesting_shares_delegation_evaluator::do_apply(const reject_vesting_shares_delegation_operation& op) {

0 commit comments

Comments
 (0)