Scorum
steemit_bounty_account_initializator.cpp
Go to the documentation of this file.
3 
6 
9 
11 
12 #include <fc/exception/exception.hpp>
13 
14 namespace scorum {
15 namespace chain {
16 namespace genesis {
17 
19 {
20  if (!is_steemit_pool_exists(ctx))
21  {
22  dlog("There is no steemit bounty account supply.");
23  return;
24  }
25 
26  account_service_i& account_service = ctx.services().account_service();
27 
29 
30  check_accounts(ctx);
31 
32  for (auto& account : ctx.genesis_state().steemit_bounty_accounts)
33  {
34  const auto& account_obj = account_service.get_account(account.name);
35 
36  account_service.increase_scorumpower(account_obj, account.sp_amount);
37  }
38 }
39 
40 bool steemit_bounty_account_initializator_impl::is_steemit_pool_exists(initializator_context& ctx)
41 {
43  || !ctx.genesis_state().steemit_bounty_accounts.empty();
44 }
45 
46 void steemit_bounty_account_initializator_impl::check_accounts(initializator_context& ctx)
47 {
48  account_service_i& account_service = ctx.services().account_service();
49 
50  asset sp_accounts_supply = ctx.genesis_state().steemit_bounty_accounts_supply;
51 
52  for (auto& account : ctx.genesis_state().steemit_bounty_accounts)
53  {
54  FC_ASSERT(!account.name.empty(), "Account 'name' should not be empty.");
55 
56  account_service.check_account_existence(account.name);
57 
58  FC_ASSERT(account.sp_amount.symbol() == SP_SYMBOL, "Invalid asset symbol for '${1}'.", ("1", account.name));
59 
60  FC_ASSERT(account.sp_amount.amount > (share_value_type)0, "Invalid asset amount for '${1}'.",
61  ("1", account.name));
62 
63  sp_accounts_supply -= account.sp_amount;
64  }
65 
66  FC_ASSERT(sp_accounts_supply.amount == (share_value_type)0,
67  "'steemit_bounty_accounts_supply' must be sum of all steemit_bounty_accounts supply.");
68 }
69 }
70 }
71 }
const genesis_state_type & genesis_state() const
data_service_factory_i & services() const
#define SP_SYMBOL
Definition: config.hpp:104
int64_t share_value_type
Definition: types.hpp:72
Definition: asset.cpp:15
virtual const account_object & get_account(const account_name_type &) const =0
virtual void check_account_existence(const account_name_type &, const optional< const char * > &context_type_name=optional< const char * >()) const =0
virtual void increase_scorumpower(const account_object &account, const asset &amount)=0
std::vector< steemit_bounty_account_type > steemit_bounty_accounts
asset_symbol_type symbol() const
Definition: asset.hpp:32
share_type amount
Definition: asset.hpp:31