Scorum
account.cpp
Go to the documentation of this file.
2 
6 
8 
9 #include <scorum/rewards_math/formulas.hpp>
10 
11 #include <boost/lambda/lambda.hpp>
12 #include <boost/multi_index/detail/unbounded.hpp>
13 
14 namespace scorum {
15 namespace chain {
16 
18  : base_service_type(db)
19  , _dgp_svc(dgp_svc)
20  , _witness_svc(witness_svc)
21 {
22 }
23 
24 const account_object& dbs_account::get(const account_id_type& account_id) const
25 {
26  try
27  {
28  return get_by<by_id>(account_id);
29  }
30  FC_CAPTURE_AND_RETHROW((account_id))
31 }
32 
33 const account_object& dbs_account::get_account(const account_name_type& name) const
34 {
35  try
36  {
37  return get_by<by_name>(name);
38  }
39  FC_CAPTURE_AND_RETHROW((name))
40 }
41 
43 {
44  return find_by<by_name>(name) != nullptr;
45 }
46 
47 const account_authority_object& dbs_account::get_account_authority(const account_name_type& name) const
48 {
49  try
50  {
51  return db_impl().get<account_authority_object, by_account>(name);
52  }
53  FC_CAPTURE_AND_RETHROW((name))
54 }
55 
57  const optional<const char*>& context_type_name) const
58 {
59  auto acc = find_by<by_name>(name);
60  if (context_type_name.valid())
61  {
62  FC_ASSERT(acc != nullptr, "\"${1}\" \"${2}\" must exist.", ("1", *context_type_name)("2", name));
63  }
64  else
65  {
66  FC_ASSERT(acc != nullptr, "Account \"${1}\" must exist.", ("1", name));
67  }
68 }
69 
71  const optional<const char*>& context_type_name) const
72 {
73  for (const auto& a : names)
74  {
75  check_account_existence(a.first, context_type_name);
76  }
77 }
78 
79 const account_object& dbs_account::create_initial_account(const account_name_type& new_account_name,
80  const public_key_type& memo_key,
81  const asset& balance,
82  const std::string& json_metadata)
83 {
84  FC_ASSERT(new_account_name.size() > 0, "Account 'name' should not be empty.");
85  FC_ASSERT(balance.symbol() == SCORUM_SYMBOL, "Invalid asset type (symbol) for balance.");
86 
88  if (memo_key != public_key_type())
89  {
90  owner.add_authority(memo_key, 1);
91  owner.weight_threshold = 1;
92  }
93  const auto& new_account
94  = create_account(new_account_name, account_name_type(), memo_key, json_metadata, owner, owner, owner);
95 
96  update(new_account, [&](account_object& acc) {
97  acc.created_by_genesis = true;
98  acc.balance = balance;
99  });
100 
101  return new_account;
102 }
103 
104 const account_object& dbs_account::create_account(const account_name_type& new_account_name,
105  const account_name_type& creator_name,
106  const public_key_type& memo_key,
107  const std::string& json_metadata,
108  const authority& owner,
109  const authority& active,
110  const authority& posting)
111 {
112  const auto& new_account = create([&](account_object& acc) {
113  acc.name = new_account_name;
114  acc.recovery_account = creator_name;
115  acc.memo_key = memo_key;
116  acc.created = _dgp_svc.head_block_time();
117 #ifndef IS_LOW_MEM
118  fc::from_string(acc.json_metadata, json_metadata);
119 #endif
120  });
121 
122  if (memo_key != public_key_type())
123  {
124  db_impl().create<account_authority_object>([&](account_authority_object& auth) {
125  auth.account = new_account_name;
126  auth.owner = owner;
127  auth.active = active;
128  auth.posting = posting;
129  auth.last_owner_update = fc::time_point_sec::min();
130  });
131  }
132 
133  return new_account;
134 }
135 
136 const account_object& dbs_account::create_account(const account_name_type& new_account_name,
137  const account_name_type& creator_name,
138  const public_key_type& memo_key,
139  const std::string& json_metadata,
140  const authority& owner,
141  const authority& active,
142  const authority& posting,
143  const asset& fee)
144 {
145  FC_ASSERT(fee.symbol() == SCORUM_SYMBOL, "invalid asset type (symbol)");
146 
147  if (fee.amount > 0)
148  decrease_balance(get_account(creator_name), fee);
149 
150  const auto& new_account
151  = create_account(new_account_name, creator_name, memo_key, json_metadata, owner, active, posting);
152 
153  if (fee.amount > 0)
154  create_scorumpower(new_account, fee);
155 
156  return new_account;
157 }
158 
159 const account_object& dbs_account::create_account_with_delegation(const account_name_type& new_account_name,
160  const account_name_type& creator_name,
161  const public_key_type& memo_key,
162  const std::string& json_metadata,
163  const authority& owner,
164  const authority& active,
165  const authority& posting,
166  const asset& fee,
167  const asset& delegation)
168 {
169  FC_ASSERT(fee.symbol() == SCORUM_SYMBOL, "invalid asset type (symbol)");
170  FC_ASSERT(delegation.symbol() == SP_SYMBOL, "invalid asset type (symbol)");
171 
172  const auto& creator = get_account(creator_name);
173 
174  update(creator, [&](account_object& c) { c.delegated_scorumpower += delegation; });
175 
176  decrease_balance(creator, fee);
177 
178  const auto& new_account
179  = create_account(new_account_name, creator_name, memo_key, json_metadata, owner, active, posting);
180 
181  update(new_account, [&](account_object& acc) { acc.received_scorumpower = delegation; });
182 
183  if (delegation.amount > 0)
184  {
185  time_point_sec t = _dgp_svc.head_block_time();
186 
187  db_impl().create<scorumpower_delegation_object>([&](scorumpower_delegation_object& vdo) {
188  vdo.delegator = creator_name;
189  vdo.delegatee = new_account_name;
190  vdo.scorumpower = delegation;
191  vdo.min_delegation_time = t + SCORUM_CREATE_ACCOUNT_DELEGATION_TIME;
192  });
193  }
194 
195  if (fee.amount > 0)
196  create_scorumpower(new_account, fee);
197 
198  return new_account;
199 }
200 
201 const account_object& dbs_account::create_account_with_bonus(const account_name_type& new_account_name,
202  const account_name_type& creator_name,
203  const public_key_type& memo_key,
204  const std::string& json_metadata,
205  const authority& owner,
206  const authority& active,
207  const authority& posting,
208  const asset& bonus)
209 {
210  FC_ASSERT(bonus.symbol() == SCORUM_SYMBOL, "invalid asset type (symbol)");
211 
212  const auto& new_account
213  = create_account(new_account_name, creator_name, memo_key, json_metadata, owner, active, posting);
214 
215  if (bonus.amount > 0)
216  {
217  create_scorumpower(new_account, bonus);
218  }
219 
220  return new_account;
221 }
222 
223 void dbs_account::update_acount(const account_object& account,
224  const account_authority_object& account_authority,
225  const public_key_type& memo_key,
226  const std::string& json_metadata,
227  const optional<authority>& owner,
228  const optional<authority>& active,
229  const optional<authority>& posting)
230 {
231  time_point_sec t = _dgp_svc.head_block_time();
232 
233  update(account, [&](account_object& acc) {
234  if (memo_key != public_key_type())
235  acc.memo_key = memo_key;
236 
237  if ((active || owner) && acc.active_challenged)
238  {
239  acc.active_challenged = false;
240  acc.last_active_proved = t;
241  }
242 
243  acc.last_account_update = t;
244 
245 #ifndef IS_LOW_MEM
246  if (json_metadata.size() > 0)
247  fc::from_string(acc.json_metadata, json_metadata);
248 #endif
249  });
250 
251  if (active || posting)
252  {
253  db_impl().modify(account_authority, [&](account_authority_object& auth) {
254  if (active)
255  auth.active = *active;
256  if (posting)
257  auth.posting = *posting;
258  });
259  }
260 }
261 
262 void dbs_account::update_owner_authority(const account_object& account, const authority& owner_authority)
263 {
264  time_point_sec t = _dgp_svc.head_block_time();
265 
266  db_impl().create<owner_authority_history_object>([&](owner_authority_history_object& hist) {
267  hist.account = account.name;
268  hist.previous_owner_authority = db_impl().get<account_authority_object, by_account>(account.name).owner;
269  hist.last_valid_time = t;
270  });
271 
272  db_impl().modify(db_impl().get<account_authority_object, by_account>(account.name),
273  [&](account_authority_object& auth) {
274  auth.owner = owner_authority;
275  auth.last_owner_update = t;
276  });
277 }
278 
279 void dbs_account::increase_balance(const account_object& account, const asset& amount)
280 {
281  // clang-format off
282  FC_ASSERT(amount.symbol() == SCORUM_SYMBOL, "invalid asset type (symbol)");
283  update(account, [&](account_object& acnt) { acnt.balance += amount; });
284 
285  _dgp_svc.update([&](dynamic_global_property_object& props) {
286  props.circulating_capital += amount;
287  });
288  // clang-format on
289 }
290 
291 void dbs_account::increase_balance(account_name_type account_name, const asset& amount)
292 {
293  const auto& acc = get_account(account_name);
294  increase_balance(acc, amount);
295 }
296 
297 void dbs_account::decrease_balance(const account_object& account, const asset& amount)
298 {
299  increase_balance(account, -amount);
300 }
301 
302 void dbs_account::increase_pending_balance(const account_object& account, const asset& amount)
303 {
304  FC_ASSERT(amount.symbol() == SCORUM_SYMBOL, "invalid asset type (symbol)");
305  update(account, [&](account_object& acnt) { acnt.active_sp_holders_pending_scr_reward += amount; });
306 
307  _dgp_svc.update([&](dynamic_global_property_object& props) { props.total_pending_scr += amount; });
308 }
309 
310 void dbs_account::decrease_pending_balance(const account_object& account, const asset& amount)
311 {
312  increase_pending_balance(account, -amount);
313 }
314 
315 void dbs_account::increase_scorumpower(const account_object& account, const asset& amount)
316 {
317  FC_ASSERT(amount.symbol() == SP_SYMBOL, "invalid asset type (symbol)");
318  update(account, [&](account_object& a) { a.scorumpower += amount; });
319 
320  _dgp_svc.update([&](dynamic_global_property_object& props) {
321  props.circulating_capital += asset(amount.amount, SCORUM_SYMBOL);
322  props.total_scorumpower += amount;
323  });
324 
325  adjust_proxied_witness_votes(account, amount.amount);
326 }
327 
328 void dbs_account::decrease_scorumpower(const account_object& account, const asset& amount)
329 {
330  increase_scorumpower(account, -amount);
331 }
332 
333 void dbs_account::increase_pending_scorumpower(const account_object& account, const asset& amount)
334 {
335  FC_ASSERT(amount.symbol() == SP_SYMBOL, "invalid asset type (symbol)");
336  update(account, [&](account_object& acnt) { acnt.active_sp_holders_pending_sp_reward += amount; });
337 
338  _dgp_svc.update([&](dynamic_global_property_object& props) { props.total_pending_sp += amount; });
339 }
340 
341 void dbs_account::decrease_pending_scorumpower(const account_object& account, const asset& amount)
342 {
343  increase_pending_scorumpower(account, -amount);
344 }
345 
346 const asset dbs_account::create_scorumpower(const account_object& to_account, const asset& scorum)
347 {
348  try
349  {
350  asset new_scorumpower = asset(scorum.amount, SP_SYMBOL);
351 
352  increase_scorumpower(to_account, new_scorumpower);
353 
354  return new_scorumpower;
355  }
356  FC_CAPTURE_AND_RETHROW((to_account.name)(scorum))
357 }
358 
359 void dbs_account::increase_delegated_scorumpower(const account_object& account, const asset& amount)
360 {
361  FC_ASSERT(amount.symbol() == SP_SYMBOL, "invalid asset type (symbol)");
362  update(account, [&](account_object& a) { a.delegated_scorumpower += amount; });
363 }
364 
366 {
367  const auto& account = get_account(account_name);
368  increase_received_scorumpower(account, amount);
369 }
370 
371 void dbs_account::increase_received_scorumpower(const account_object& account, const asset& amount)
372 {
373  FC_ASSERT(amount.symbol() == SP_SYMBOL, "invalid asset type (symbol)");
374  update(account, [&](account_object& a) { a.received_scorumpower += amount; });
375 }
376 
378 {
379  const auto& account = get_account(account_name);
380  decrease_received_scorumpower(account, amount);
381 }
382 
383 void dbs_account::decrease_received_scorumpower(const account_object& account, const asset& amount)
384 {
385  increase_received_scorumpower(account, -amount);
386 }
387 
388 void dbs_account::drop_challenged(const account_object& account)
389 {
390  time_point_sec t = _dgp_svc.head_block_time();
391 
392  if (account.active_challenged)
393  {
394  update(account, [&](account_object& a) {
395  a.active_challenged = false;
396  a.last_active_proved = t;
397  });
398  }
399 }
400 
401 void dbs_account::prove_authority(const account_object& account, bool require_owner)
402 {
403  time_point_sec t = _dgp_svc.head_block_time();
404 
405  update(account, [&](account_object& a) {
406  a.active_challenged = false;
407  a.last_active_proved = t;
408  if (require_owner)
409  {
410  a.owner_challenged = false;
411  a.last_owner_proved = t;
412  }
413  });
414 }
415 
416 void dbs_account::increase_witnesses_voted_for(const account_object& account)
417 {
418  update(account, [&](account_object& a) { a.witnesses_voted_for++; });
419 }
420 
421 void dbs_account::decrease_witnesses_voted_for(const account_object& account)
422 {
423  update(account, [&](account_object& a) { a.witnesses_voted_for--; });
424 }
425 
426 void dbs_account::add_post(const account_object& author_account, const account_name_type& parent_author_name)
427 {
428  time_point_sec t = _dgp_svc.head_block_time();
429 
430  update(author_account, [&](account_object& a) {
431  if (parent_author_name == SCORUM_ROOT_POST_PARENT_ACCOUNT)
432  {
433  a.last_root_post = t;
434  }
435  a.last_post = t;
436  });
437 }
438 
439 void dbs_account::update_voting_power(const account_object& account, uint16_t voting_power)
440 {
441  if (voting_power < account.voting_power)
442  {
444  }
445 
446  time_point_sec t = _dgp_svc.head_block_time();
447 
448  update(account, [&](account_object& a) {
449  a.voting_power = voting_power;
450  a.last_vote_time = t;
451  a.voting_power_restoring_time = scorum::rewards_math::calculate_expected_restoring_time(
452  voting_power, t, SCORUM_VOTE_REGENERATION_SECONDS);
453  a.vote_reward_competitive_sp = a.effective_scorumpower();
454  });
455 }
456 
457 void dbs_account::update_active_sp_holders_cashout_time(const account_object& account)
458 {
459  if (account.active_sp_holders_cashout_time == fc::time_point_sec::maximum())
460  {
461  update(account, [&](account_object& a) {
462  fc::time_point_sec cashout_time = _dgp_svc.head_block_time() + SCORUM_ACTIVE_SP_HOLDERS_REWARD_PERIOD;
463  a.active_sp_holders_cashout_time = cashout_time;
464  });
465  }
466 }
467 
469  const authority& new_owner_authority)
470 {
471  time_point_sec t = _dgp_svc.head_block_time();
472 
473  const auto& recovery_request_idx
474  = db_impl().get_index<account_recovery_request_index>().indices().get<by_account>();
475  auto request = recovery_request_idx.find(account_to_recover);
476 
477  if (request == recovery_request_idx.end()) // New Request
478  {
479  FC_ASSERT(!new_owner_authority.is_impossible(), "Cannot recover using an impossible authority.");
480  FC_ASSERT(new_owner_authority.weight_threshold, "Cannot recover using an open authority.");
481 
482  check_account_existence(new_owner_authority.account_auths);
483 
484  db_impl().create<account_recovery_request_object>([&](account_recovery_request_object& req) {
485  req.account_to_recover = account_to_recover;
486  req.new_owner_authority = new_owner_authority;
488  });
489  }
490  else if (new_owner_authority.weight_threshold == 0) // Cancel Request if authority is open
491  {
492  db_impl().remove(*request);
493  }
494  else // Change Request
495  {
496  FC_ASSERT(!new_owner_authority.is_impossible(), "Cannot recover using an impossible authority.");
497 
498  check_account_existence(new_owner_authority.account_auths);
499 
500  db_impl().modify(*request, [&](account_recovery_request_object& req) {
501  req.new_owner_authority = new_owner_authority;
503  });
504  }
505 }
506 
507 void dbs_account::submit_account_recovery(const account_object& account_to_recover,
508  const authority& new_owner_authority,
509  const authority& recent_owner_authority)
510 {
511  time_point_sec t = _dgp_svc.head_block_time();
512 
513  const auto& recovery_request_idx
514  = db_impl().get_index<account_recovery_request_index>().indices().get<by_account>();
515  auto request = recovery_request_idx.find(account_to_recover.name);
516 
517  FC_ASSERT(request != recovery_request_idx.end(), "There are no active recovery requests for this account.");
518  FC_ASSERT(request->new_owner_authority == new_owner_authority,
519  "New owner authority does not match recovery request.");
520 
521  const auto& recent_auth_idx = db_impl().get_index<owner_authority_history_index>().indices().get<by_account>();
522  auto hist = recent_auth_idx.lower_bound(account_to_recover.name);
523  bool found = false;
524 
525  while (hist != recent_auth_idx.end() && hist->account == account_to_recover.name && !found)
526  {
527  found = hist->previous_owner_authority == recent_owner_authority;
528  if (found)
529  break;
530  ++hist;
531  }
532 
533  FC_ASSERT(found, "Recent authority not found in authority history.");
534 
535  db_impl().remove(*request); // Remove first, update_owner_authority may invalidate iterator
536  update_owner_authority(account_to_recover, new_owner_authority);
537  update(account_to_recover, [&](account_object& a) { a.last_account_recovery = t; });
538 }
539 
540 void dbs_account::change_recovery_account(const account_object& account_to_recover,
541  const account_name_type& new_recovery_account_name)
542 {
543  time_point_sec t = _dgp_svc.head_block_time();
544 
545  const auto& change_recovery_idx
546  = db_impl().get_index<change_recovery_account_request_index>().indices().get<by_account>();
547  auto request = change_recovery_idx.find(account_to_recover.name);
548 
549  if (request == change_recovery_idx.end()) // New request
550  {
551  db_impl().create<change_recovery_account_request_object>([&](change_recovery_account_request_object& req) {
552  req.account_to_recover = account_to_recover.name;
553  req.recovery_account = new_recovery_account_name;
554  req.effective_on = t + SCORUM_OWNER_AUTH_RECOVERY_PERIOD;
555  });
556  }
557  else if (account_to_recover.recovery_account != new_recovery_account_name) // Change existing request
558  {
559  db_impl().modify(*request, [&](change_recovery_account_request_object& req) {
560  req.recovery_account = new_recovery_account_name;
561  req.effective_on = t + SCORUM_OWNER_AUTH_RECOVERY_PERIOD;
562  });
563  }
564  else // Request exists and changing back to current recovery account
565  {
566  db_impl().remove(*request);
567  }
568 }
569 
570 void dbs_account::update_voting_proxy(const account_object& account, const optional<account_object>& proxy_account)
571 {
573  std::array<share_type, SCORUM_MAX_PROXY_RECURSION_DEPTH + 1> delta;
574  delta[0] = -account.scorumpower.amount;
575  for (int i = 0; i < SCORUM_MAX_PROXY_RECURSION_DEPTH; ++i)
576  delta[i + 1] = -account.proxied_vsf_votes[i];
577 
578  adjust_proxied_witness_votes(account, delta);
579 
580  if (proxy_account.valid())
581  {
582  flat_set<account_id_type> proxy_chain({ account.id, (*proxy_account).id });
583  proxy_chain.reserve(SCORUM_MAX_PROXY_RECURSION_DEPTH + 1);
584 
586  auto cprox = &(*proxy_account);
587  while (cprox->proxy.size() != 0)
588  {
589  const auto next_proxy = get_account(cprox->proxy);
590  FC_ASSERT(proxy_chain.insert(next_proxy.id).second, "This proxy would create a proxy loop.");
591  cprox = &next_proxy;
592  FC_ASSERT(proxy_chain.size() <= SCORUM_MAX_PROXY_RECURSION_DEPTH, "Proxy chain is too long.");
593  }
594 
596  clear_witness_votes(account);
597 
598  update(account, [&](account_object& a) { a.proxy = (*proxy_account).name; });
599 
601  for (int i = 0; i <= SCORUM_MAX_PROXY_RECURSION_DEPTH; ++i)
602  delta[i] = -delta[i];
603  adjust_proxied_witness_votes(account, delta);
604  }
605  else
606  {
607  update(account, [&](account_object& a) { a.proxy = account_name_type(SCORUM_PROXY_TO_SELF_ACCOUNT); });
608  }
609 }
610 
611 void dbs_account::clear_witness_votes(const account_object& account)
612 {
613  const auto& vidx = db_impl().get_index<witness_vote_index>().indices().get<by_account_witness>();
614  auto itr = vidx.lower_bound(boost::make_tuple(account.id, witness_id_type()));
615  while (itr != vidx.end() && itr->account == account.id)
616  {
617  const auto& current = *itr;
618  ++itr;
619  db_impl().remove(current);
620  }
621 
622  update(account, [&](account_object& acc) { acc.witnesses_voted_for = 0; });
623 }
624 
626  const account_object& account, const std::array<share_type, SCORUM_MAX_PROXY_RECURSION_DEPTH + 1>& delta, int depth)
627 {
628  if (account.proxy != SCORUM_PROXY_TO_SELF_ACCOUNT)
629  {
632  return;
633 
634  const auto& proxy = get_account(account.proxy);
635 
636  update(proxy, [&](account_object& a) {
637  for (int i = SCORUM_MAX_PROXY_RECURSION_DEPTH - depth - 1; i >= 0; --i)
638  {
639  a.proxied_vsf_votes[i + depth] += delta[i];
640  }
641  });
642 
643  adjust_proxied_witness_votes(proxy, delta, depth + 1);
644  }
645  else
646  {
647  share_type total_delta = 0;
648  for (int i = SCORUM_MAX_PROXY_RECURSION_DEPTH - depth; i >= 0; --i)
649  total_delta += delta[i];
650 
651  _witness_svc.adjust_witness_votes(account, total_delta);
652  }
653 }
654 
655 void dbs_account::adjust_proxied_witness_votes(const account_object& account, const share_type& delta, int depth)
656 {
657  if (account.proxy != SCORUM_PROXY_TO_SELF_ACCOUNT)
658  {
661  return;
662 
663  const auto& proxy = get_account(account.proxy);
664 
665  update(proxy, [&](account_object& a) { a.proxied_vsf_votes[depth] += delta; });
666 
667  adjust_proxied_witness_votes(proxy, delta, depth + 1);
668  }
669  else
670  {
671  _witness_svc.adjust_witness_votes(account, delta);
672  }
673 }
674 
676 {
677  fc::time_point_sec min_vote_time_for_cashout = _dgp_svc.head_block_time();
678 
679  return get_range_by<by_voting_power_restoring_time>(min_vote_time_for_cashout < boost::lambda::_1,
681 }
682 
684 {
685  foreach_by<by_id>(call);
686 }
688 {
689  try
690  {
691  return get_range_by<by_active_sp_holders_cashout_time>(::boost::multi_index::unbounded,
692  ::boost::lambda::_1 <= std::make_tuple(until, ALL_IDS));
693  }
694  FC_CAPTURE_AND_RETHROW((until))
695 }
696 
698 {
699  accounts_total totals;
700 
701  const auto& account_idx = db_impl().get_index<account_index>().indices().get<by_name>();
702  for (auto itr = account_idx.begin(); itr != account_idx.end(); ++itr)
703  {
704  totals.scr += itr->balance;
705  totals.sp += itr->scorumpower;
706  totals.pending_scr += itr->active_sp_holders_pending_scr_reward;
707  totals.pending_sp += itr->active_sp_holders_pending_sp_reward;
708 
709  totals.vsf_votes += (itr->proxy == SCORUM_PROXY_TO_SELF_ACCOUNT
710  ? itr->witness_vote_weight()
712  ? itr->proxied_vsf_votes[SCORUM_MAX_PROXY_RECURSION_DEPTH - 1]
713  : itr->scorumpower.amount));
714  }
715 
716  return totals;
717 }
718 
719 } // namespace chain
720 } // namespace scorum
virtual account_refs_type get_by_cashout_time(const fc::time_point_sec &until) const override
Definition: account.cpp:687
virtual void add_post(const account_object &author_account, const account_name_type &parent_author_name) override
Definition: account.cpp:426
virtual void increase_delegated_scorumpower(const account_object &account, const asset &amount) override
Definition: account.cpp:359
virtual void increase_pending_scorumpower(const account_object &account, const asset &amount) override
Definition: account.cpp:333
virtual void update_owner_authority(const account_object &account, const authority &owner_authority) override
Definition: account.cpp:262
virtual void decrease_scorumpower(const account_object &account, const asset &amount) override
Definition: account.cpp:328
virtual const account_object & create_account_with_delegation(const account_name_type &new_account_name, const account_name_type &creator_name, const public_key_type &memo_key, const std::string &json_metadata, const authority &owner, const authority &active, const authority &posting, const asset &fee_in_scorums, const asset &delegation_in_scorumpower) override
Definition: account.cpp:159
virtual void increase_received_scorumpower(account_name_type account_name, const asset &amount) override
Definition: account.cpp:365
virtual const account_authority_object & get_account_authority(const account_name_type &) const override
Definition: account.cpp:47
virtual void foreach_account(account_call_type &&) const override
Definition: account.cpp:683
virtual void update_voting_power(const account_object &account, uint16_t voting_power) override
Definition: account.cpp:439
virtual const account_object & create_account_with_bonus(const account_name_type &new_account_name, const account_name_type &creator_name, const public_key_type &memo_key, const std::string &json_metadata, const authority &owner, const authority &active, const authority &posting, const asset &bonus) override
Definition: account.cpp:201
virtual void increase_balance(const account_object &account, const asset &amount) override
Definition: account.cpp:279
virtual account_refs_type get_active_sp_holders() const override
Definition: account.cpp:675
virtual void check_account_existence(const account_name_type &, const optional< const char * > &context_type_name=optional< const char * >()) const override
Definition: account.cpp:56
virtual void decrease_balance(const account_object &account, const asset &amount) override
Definition: account.cpp:297
virtual void decrease_pending_scorumpower(const account_object &account, const asset &amount) override
Definition: account.cpp:341
virtual void decrease_pending_balance(const account_object &account, const asset &amount) override
Definition: account.cpp:310
virtual void drop_challenged(const account_object &account) override
Definition: account.cpp:388
virtual void clear_witness_votes(const account_object &account) override
Definition: account.cpp:611
virtual void update_active_sp_holders_cashout_time(const account_object &account) override
Definition: account.cpp:457
virtual void update_acount(const account_object &account, const account_authority_object &account_authority, const public_key_type &memo_key, const std::string &json_metadata, const optional< authority > &owner, const optional< authority > &active, const optional< authority > &posting) override
Definition: account.cpp:223
virtual void increase_scorumpower(const account_object &account, const asset &amount) override
Definition: account.cpp:315
virtual void decrease_witnesses_voted_for(const account_object &account) override
Definition: account.cpp:421
virtual const account_object & create_initial_account(const account_name_type &new_account_name, const public_key_type &memo_key, const asset &balance_in_scorums, const std::string &json_metadata) override
Definition: account.cpp:79
virtual void change_recovery_account(const account_object &account_to_recover, const account_name_type &new_recovery_account) override
Definition: account.cpp:540
virtual void decrease_received_scorumpower(account_name_type account_name, const asset &amount) override
Definition: account.cpp:377
virtual void create_account_recovery(const account_name_type &account_to_recover_name, const authority &new_owner_authority) override
Definition: account.cpp:468
virtual const asset create_scorumpower(const account_object &to_account, const asset &scorum) override
Definition: account.cpp:346
dbs_account(dba::db_index &, dynamic_global_property_service_i &, witness_service_i &)
Definition: account.cpp:17
const account_object & create_account(const account_name_type &new_account_name, const account_name_type &creator_name, const public_key_type &memo_key, const std::string &json_metadata, const authority &owner, const authority &active, const authority &posting) override
Definition: account.cpp:104
virtual void submit_account_recovery(const account_object &account_to_recover, const authority &new_owner_authority, const authority &recent_owner_authority) override
Definition: account.cpp:507
virtual void increase_pending_balance(const account_object &account, const asset &amount) override
Definition: account.cpp:302
virtual void increase_witnesses_voted_for(const account_object &account) override
Definition: account.cpp:416
virtual void adjust_proxied_witness_votes(const account_object &account, const std::array< share_type, SCORUM_MAX_PROXY_RECURSION_DEPTH+1 > &delta, int depth=0) override
Definition: account.cpp:625
virtual void prove_authority(const account_object &account, bool require_owner) override
Definition: account.cpp:401
virtual const account_object & get_account(const account_name_type &) const override
Definition: account.cpp:33
virtual accounts_total accounts_circulating_capital() const override
Definition: account.cpp:697
virtual void update_voting_proxy(const account_object &account, const optional< account_object > &proxy_account) override
Definition: account.cpp:570
dba::db_index & db_impl()
Definition: dbs_base.cpp:22
virtual const object_type & create(const modifier_type &modifier) override
virtual void update(const modifier_type &modifier) override
virtual const object_type & get() const override
asset total_scorumpower
Total SP on accounts scorumpower.
asset circulating_capital
Total SCR and SP on circulating (on account balances). circulating_capital <= total_supply.
#define SCORUM_OWNER_AUTH_RECOVERY_PERIOD
Definition: config.hpp:138
#define SCORUM_ACTIVE_SP_HOLDERS_REWARD_PERIOD
Definition: config.hpp:126
#define SP_SYMBOL
Definition: config.hpp:104
#define SCORUM_SYMBOL
Definition: config.hpp:102
#define SCORUM_VOTE_REGENERATION_SECONDS
Definition: config.hpp:191
#define SCORUM_MAX_PROXY_RECURSION_DEPTH
Definition: config.hpp:186
#define SCORUM_ACCOUNT_RECOVERY_REQUEST_EXPIRATION_PERIOD
Definition: config.hpp:139
#define SCORUM_CREATE_ACCOUNT_DELEGATION_TIME
Definition: config.hpp:221
const unbounded_placeholder unbounded
shared_multi_index_container< witness_vote_object, indexed_by< ordered_unique< tag< by_id >, member< witness_vote_object, witness_vote_id_type, &witness_vote_object::id > >, ordered_unique< tag< by_account_witness >, composite_key< witness_vote_object, member< witness_vote_object, account_id_type, &witness_vote_object::account >, member< witness_vote_object, witness_id_type, &witness_vote_object::witness > >, composite_key_compare< std::less< account_id_type >, std::less< witness_id_type > > >, ordered_unique< tag< by_witness_account >, composite_key< witness_vote_object, member< witness_vote_object, witness_id_type, &witness_vote_object::witness >, member< witness_vote_object, account_id_type, &witness_vote_object::account > >, composite_key_compare< std::less< witness_id_type >, std::less< account_id_type > > > > > witness_vote_index
fc::safe< share_value_type > share_type
Definition: types.hpp:73
flat_map< account_name_type, authority_weight_type > account_authority_map
Definition: authority.hpp:8
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
Definition: asset.cpp:15
#define ALL_IDS
std::vector< cref_type > account_refs_type
Definition: account.hpp:167
typename base_service_i::call_type account_call_type
Definition: account.hpp:171
asset scr
sum of all SCR balances
Definition: account.hpp:13
asset pending_scr
sum of all pending SCR balances
Definition: account.hpp:19
asset sp
sum of all SP balances
Definition: account.hpp:16
asset pending_sp
sum of all pending SP balances
Definition: account.hpp:22
virtual void update(const modifier_type &modifier)=0
virtual fc::time_point_sec head_block_time() const =0
virtual void adjust_witness_votes(const account_object &account, const share_type &delta)=0
asset_symbol_type symbol() const
Definition: asset.hpp:32
share_type amount
Definition: asset.hpp:31
account_authority_map account_auths
Definition: authority.hpp:55