Skip to content

Commit

Permalink
Disable setkey if min_own_staked less then min_own_staked_for_election
Browse files Browse the repository at this point in the history
  • Loading branch information
s-medvedev authored Aug 14, 2019
1 parent 69da729 commit 34973b6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cyber.stake/src/cyber.stake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ void stake::setminstaked(name account, symbol_code token_code, int64_t min_own_s

void stake::setkey(name account, symbol_code token_code, public_key signing_key) {
staking_exists(token_code);

params params_table(table_owner, table_owner.value);
auto min_own_staked_for_election = params_table.get(token_code.raw(), "no staking for token").min_own_staked_for_election;

agents agents_table(table_owner, table_owner.value);
auto agents_idx = agents_table.get_index<"bykey"_n>();
auto agent = get_agent_itr(token_code, agents_idx, account);
eosio::check(agent->proxy_level || agent->min_own_staked >= min_own_staked_for_election,
"min_own_staked can't be less than min_own_staked_for_election for users with an ultimate level");

modify_candidate(account, token_code, [signing_key](auto& a) {
a.signing_key = signing_key;
a.enabled = signing_key != public_key{};
Expand Down

0 comments on commit 34973b6

Please sign in to comment.