Improving genesis block for PeerPlays

according http://syncad.storm.pl:56780/blocktrades/graphene/
	improving, refactoring code - resigning from unsafe static_cast, implementing constructor copiny from base class
This commit is contained in:
Roman Olearski 2016-10-08 22:25:18 +02:00
parent 227c89a453
commit 2e3cd4a75c
2 changed files with 14 additions and 17 deletions

View file

@ -119,15 +119,6 @@ bool is_exchange(const std::string& account_name)
account_name == "btc38btsxwithdrawal";
}
class my_account_balance_object : public graphene::chain::account_balance_object
{
public:
graphene::chain::share_type initial_balance;
graphene::chain::share_type orders;
graphene::chain::share_type collaterals;
graphene::chain::share_type sharedrop;
};
void generate_genesis_plugin::generate_snapshot()
{
ilog("generate genesis plugin: generating snapshot now");
@ -144,8 +135,8 @@ void generate_genesis_plugin::generate_snapshot()
for (auto balance_iter = balance_index.begin(); balance_iter != balance_index.end() && balance_iter->asset_type == graphene::chain::asset_id_type(); ++balance_iter)
if (!is_special_account(balance_iter->owner) && !is_exchange(balance_iter->owner(d).name))
{
// todo : can static cast be dangerous : consider using CRTP idiom
db_balances.emplace_back(static_cast<const my_account_balance_object&>(*balance_iter));
// it is possible due to constructor
db_balances.emplace_back(*balance_iter);
}
// walk through the balances; this index has the largest BTS balances first
@ -210,12 +201,6 @@ void generate_genesis_plugin::generate_snapshot()
effective_total_bts_balance += balance_iter->balance;
}
// cosmetic, otherwise mess in tail of log
for (auto iter = balance_iter; iter != db_balances.end(); ++iter)
{
iter->sharedrop = 0;
}
// our iterator is just after the smallest balance we will process,
// walk it backwards towards the larger balances, distributing the sharedrop as we go
graphene::chain::share_type remaining_amount_to_distribute = total_amount_to_distribute;

View file

@ -56,4 +56,16 @@ private:
std::string _genesis_filename;
};
class my_account_balance_object : public graphene::chain::account_balance_object
{
public:
// constructor copying from base class
my_account_balance_object(const graphene::chain::account_balance_object& abo) : graphene::chain::account_balance_object(abo) {}
graphene::chain::share_type initial_balance;
graphene::chain::share_type orders;
graphene::chain::share_type collaterals;
graphene::chain::share_type sharedrop;
};
} } //graphene::generate_genesis_plugin