Scorum
registration_initializator.cpp
Go to the documentation of this file.
3 
6 
8 
9 namespace scorum {
10 namespace chain {
11 namespace genesis {
12 
14 {
15  if (!is_registration_pool_exists(ctx))
16  {
17  dlog("There is no registration pool.");
18  return;
19  }
20 
21  FC_ASSERT(ctx.genesis_state().rewards_supply.symbol() == SCORUM_SYMBOL);
23 
24  // create sorted items list form genesis unordered data
25  using schedule_item_type = registration_pool_object::schedule_item;
26  using schedule_items_type = std::map<uint8_t, schedule_item_type>;
27  schedule_items_type items;
28  for (const auto& genesis_item : ctx.genesis_state().registration_schedule)
29  {
30  items.insert(schedule_items_type::value_type(
31  genesis_item.stage, schedule_item_type{ genesis_item.users, genesis_item.bonus_percent }));
32  }
33 
34  registration_pool_service_i& registration_pool_service = ctx.services().registration_pool_service();
35  registration_committee_service_i& registration_committee_service = ctx.services().registration_committee_service();
36 
37  FC_ASSERT(!registration_pool_service.is_exists());
38 
39  registration_pool_service.create_pool(ctx.genesis_state().registration_supply,
40  ctx.genesis_state().registration_bonus, items);
41 
42  using account_names_type = std::vector<account_name_type>;
43  account_names_type committee;
44  for (const auto& member : ctx.genesis_state().registration_committee)
45  {
46  committee.emplace_back(member);
47  }
48  registration_committee_service.create_committee(committee);
49 }
50 
51 bool registration_initializator_impl::is_registration_pool_exists(initializator_context& ctx)
52 {
54  || !ctx.genesis_state().registration_schedule.empty() || !ctx.genesis_state().registration_committee.empty();
55 }
56 }
57 }
58 }
const genesis_state_type & genesis_state() const
data_service_factory_i & services() const
#define SCORUM_SYMBOL
Definition: config.hpp:102
Definition: asset.cpp:15
virtual bool is_exists() const =0
std::vector< registration_schedule_item > registration_schedule
std::vector< std::string > registration_committee
virtual committee_members_cref_type create_committee(const std::vector< account_name_type > &accounts)=0
virtual const registration_pool_object & create_pool(const asset &supply, const asset &maximum_bonus, const schedule_items_type &schedule_items)=0
asset_symbol_type symbol() const
Definition: asset.hpp:32
share_type amount
Definition: asset.hpp:31