Skip to content

Commit

Permalink
Genesis: store memo keys #651
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcat committed Jun 6, 2019
1 parent 480240e commit 824ebe0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
18 changes: 16 additions & 2 deletions programs/create-genesis/genesis_create.cpp
Expand Up @@ -319,8 +319,6 @@ struct genesis_create::genesis_create_impl final {
const auto& owner = store_permission(name, config::owner_name, 0, own, usage_id++);
const auto& active = store_permission(name, config::active_name, owner.id, act, usage_id++);
const auto& posting= store_permission(name, posting_auth_name, active.id, post, usage_id++);

// TODO: do we need memo key ? #651
}

// link posting permission with gls.publish and gls.social
Expand Down Expand Up @@ -1060,6 +1058,21 @@ struct genesis_create::genesis_create_impl final {
ilog("Done.");
}

void store_memo_keys() {
ilog("Creating memo keys...");
const auto& accs = _visitor.accounts;
db.start_section(_info.golos.names.memo, N(memo), "memo_key", accs.size());
for (const auto& ac : accs) {
const auto& a = ac.second;
const auto n = name_by_acc(a.name);
db.insert(n.value, n, mvo
("name", n)
("key", public_key_type{pubkey_string(a.memo_key)})
);
}
ilog("Done.");
}

void prepare_writer(const bfs::path& out_file) {
const int n_sections = static_cast<int>(stored_contract_tables::_max) + _info.tables.size();
db.start(out_file, n_sections);
Expand Down Expand Up @@ -1097,6 +1110,7 @@ void genesis_create::write_genesis(
_impl->store_delegation_records();
_impl->store_withdrawals();
_impl->store_witnesses();
_impl->store_memo_keys();

_impl->db.finalize();

Expand Down
4 changes: 3 additions & 1 deletion programs/create-genesis/genesis_info.hpp
Expand Up @@ -136,6 +136,7 @@ struct genesis_info {
account_name posting;
account_name social;
account_name charge;
account_name memo;
} names;

struct recovery_params {
Expand Down Expand Up @@ -178,7 +179,8 @@ FC_REFLECT(cyberway::genesis::genesis_info::account, (name)(update)(permissions)
FC_REFLECT(cyberway::genesis::genesis_info::auth_link, (permission)(links))
FC_REFLECT(cyberway::genesis::genesis_info::table::row, (scope)(payer)(pk)(data))
FC_REFLECT(cyberway::genesis::genesis_info::table, (code)(table)(abi_type)(rows))
FC_REFLECT(cyberway::genesis::genesis_info::golos_config::golos_names, (issuer)(control)(vesting)(posting)(social)(charge))
FC_REFLECT(cyberway::genesis::genesis_info::golos_config::golos_names,
(issuer)(control)(vesting)(posting)(social)(charge)(memo))
FC_REFLECT(cyberway::genesis::genesis_info::golos_config::recovery_params, (wait_days))
FC_REFLECT(cyberway::genesis::genesis_info::golos_config::posts_trx_params, (expiration_hours)(initial_from))
FC_REFLECT(cyberway::genesis::genesis_info::golos_config, (domain)(names)(recovery)(max_supply)(sys_max_supply)(posts_trx))
Expand Down
1 change: 1 addition & 0 deletions programs/create-genesis/serializer.hpp
Expand Up @@ -39,6 +39,7 @@ enum class stored_contract_tables: int {
stake_agents, stake_cands,
stake_grants,
stake_stats, stake_params,
memo_key,

_max // to simplify setting tables_count of genesis container
};
Expand Down

0 comments on commit 824ebe0

Please sign in to comment.